Eminem replaced one addiction for another, only this time it was a healthy habit.

The 42-year-old rapper tells Men's Journal that after he overdosed on pills in 2007, he was "close to 230 pounds."

"I'm not sure how I got so big, but I have ideas," he said. "The coating on the Vicodin and the Valium I'd been taking for years leaves a hole in your stomach, so to avoid a stomachache, I was constantly eating -- and eating badly."

WATCH: EXCLUSIVE! Gwen Stefani on Collaborating With Eminem -- 'He's a Real Artist'

Eminem says when he finished rehab he used running as a way to "function sober."

"Unless I was blitzed out of my mind, I had trouble sleeping. So I started running. It gave me a natural endorphin high, but it also helped me sleep, so it was perfect," he explained. "It's easy to understand how people replace addiction with exercise. One addiction for another, but one that's good for them. I got an addict's brain, and when it came to running, I think I got a little carried away. I became a f**king hamster."

WATCH: Daniel Radcliffe Performs a Perfect Cover of Eminem's 'The Real Slim Shady'

The artist got so obsessed with exercise that he says he was running 17 miles a day on a treadmill.

"I would get up in the morning, and before I went to the studio, I would run eight and a half miles in about an hour. Then I'd come home and run another eight and a half," he recalled. "I started getting OCD about the calories, making sure I burned 2,000 every day. In the end I got down to about 149 pounds."

Eminem's excessive running ultimately led to him injuring himself. "All the constant pounding from the running began to tear up my hip flexors," he said.

WATCH: Eminem Calls Out Caitlyn Jenner, Bill Cosby and Donald Trump in Freestyle Rap

That's when he turned to those trusty workout DVDs. "The Real Slim Shady" rapper says he started doing Shaun T's Insanity and P90X as his daily exercise routine, and then moved on to Body Beast. "It's just me, so it helps that the Body Beast dude is over-the-top," he said of the workouts.

He also admits that it's sometimes hard to stick with exercising daily, but he's super committed.

WATCH: Demi Lovato on Possible Eminem Collaboration -- 'I Can Relate to Him on Being in Recovery'

"I still hate pullups. They're a motherf--ker, but I do them. I even fill out the log afterward. I guess I'm pretty compulsive working out," Eminem confessed. "I feel like if I step away from it for too long, if I have a crazy week and take a five-day break, it'll be like starting over. I'm afraid that if it goes beyond that, I might lose the motivation."

He added, "Once you're at a place where you've made progress and you've got some time invested in it, you don't wanna quit and give up what you started."

PHOTOS: Before and After! Shocking Celebrity Weight Loss Transformations

Eminem produced the soundtrack for this summer's boxing movie Southpaw, and like the musician, the film's star Jake Gyllenhaal also bulked up.