Ruby eating up all my CPU resources

I’ve recently been programming in Ruby on both of my Macs, a MacBook Pro with an Intel Core 2 Duo and 3 GB RAM, and an iMac with an Intel Core i3 and 4 GB RAMs. Well, I’ve been mostly using irb, the Ruby interpreter, for loads and loads of tests while writing the actual code. I usually test fragments of code interactively to see if things are working, and, thus, I open a few terminal tabs and fire up irb in them.

The thing is that I’ve noticed in the iStat Pro widget that the CPU is 90%–100% active… And both have at least two cores… with HyperThreading! Even when I quit the terminal app (iTerm in my case), the CPU is still working a lot! Then and idea came to me: launch Activity Monitor and see what application is consuming all those resources. What a surprise when I see 4 ruby processes eating up 90-ish% of the CPU!

After forcing quit those processes, everything becomes normal again! Notice the CPU usage graph before and after:

And I guess it wasn’t only eating up the CPU resources, but also the memory. And that’s happened to me with both computers. Unbelievable!

Advertisements