On 11/5/07, Pete DeLaurentis [email protected] wrote:
Hi guys,
Along the lines of Thomas question, I’ve noticed that my mongrel
rails processes start at around 50 MB, and creep up to around 100 MB
(or a little over) pretty soon after being used. Is this something
other folks are seeing (i.e. standard rails overhead), or does it
sound specific to my app?
There is probably a jump after the first request, then a slow creep
upward for a bit, then it should stabilize. If it never stabilizes,
then you have something in your code somewhere which is leaking.
Also, if anyone has any tips on finding memory leaks in mongrel,
they’d be much appreciated. I’ve played with watching the
ObjectSpace. Is this the best way?
There are some tools that help, but yeah, mostly it’s by using
objectspace and looking through your code. If the code uses an
extension, it’s easy for an extension to have a leak that doesn’t show
up so easily, though. I originally found the Array#shift leak by
using valgrind on Ruby, since all of that is C code.
Kirk: thanks for the tip on Array.shift with Ruby 1.8.5. I’ll keep
an eye out for this.
If this bites you, you can migrate to the most recent 1.8.6, or you
can change your code to not use shift. Generally when shift is used,
push is being used to stick things on one end of the array while shift
pulls them off the front. Changing that to use unshift and pop gets
around the problem.
Kirk H.