Posted by Bart ten Brinke Wed, 02 Jul 2008 14:00:33 GMT
As our mongrels were using up quite a lot of memory, so I tried to figure out what was causing this.
When running the app locally I found out that one certain page caused the mongrel to grow from 60 to 190 megabytes. A whopping 130 megabytes!
After commenting out some of the code, I realized that a single line was causing all of the memory usage
contracts = Contract.find( :all,
:conditions => ['contracts.employee_id IN (?) ', employees ],
:include => [:expertise_profile => :qualifications ] )
Ouch! The nested include of rails somehow leaks a large amount of memory. The fix was a piece of cake.
contracts = Contract.find( :all,
:conditions => ['contracts.employee_id IN (?) ', employees ],
:include => :expertise_profile )
Now my mongrel stays at 60 megabytes. I don't know if this issue persists in the new 2.1 Rails, but I'll check that soon!
