From: Joel VanderWerf Date: 2006-10-27T05:05:21+09:00 Subject: Re: debugging memory use and GC Rick DeNatale wrote: > On 10/25/06, snacktime wrote: >> What is a good way to find out what objects are not being GC'd ? I am >> seeing a strange pattern I can't figure out. The app is handling >> large files and will use up to 150mb or so of memory and then when I >> call GC.start it goes back down to around 8mb. But after a few cycles >> memory stops being reclaimed. > > Of course, what you really want to know is not just what's not getting > GCed but WHY. > > This can be a difficult problem. You really want to find the > reference paths from root objects. > > Some GC languages like Smalltalk have methods in object to get a list > of everything which references it. I haven't seen such a facility in > Ruby. Then the problem with this is that calling this method > generates additional references to the objects referencing the object > etc. This kind of heisenberg effect makes building a tool to find > reference paths difficult. > I wrote a patch for ruby 1.6/1.7 that would search for all ways of reaching an object from root objects in objectspace: http://redshift.sourceforge.net/debugging-GC/ Usage info at: http://redshift.sourceforge.net/debugging-GC/gc-patch.txt Nobu updated it for CVS as of 12 Aug 2005: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/151854 I've found this to be useful only once or twice, but in those rare cases it can be very helpful... -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407