From: Joey Marino Date: 2008-03-31T09:07:11+09:00 Subject: Re: GC help ------=_Part_1476_16954913.1206922026954 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I found out it is not the 3rd party code. I am downloading images (~320,000 ct.) as strings, and saving each to a file. The file handlers are getting closed. Using the Dike gem, I think I determined the bulk of the leaked memory is in these string variables. But what I don't understand is that the variables containing the strings are local to a method of an object and should be unreferenced when that method is done, right? I've invoked GC at the end of the method and after each iteration that the method gets called. I've even set the strings to nil after they've been saved to a file and before gc is called. The app is using 2G of ram and 4G of swap before it runs of out memory and crashes about 1/3rd of the way through. I'm really starting to doubt Ruby's ability to do memory intensive work. Any ideas? On Sun, Mar 30, 2008 at 3:53 PM, Tim Hunter wrote: > Joey Marino wrote: > > I am still running out of memory with my ruby application. For some > reason, > > there are objects that are not getting reclaimed long after their use is > up. > > I understand the mark and sweep GC algorithm. Is there a method in Ruby > to > > set an object's memory space to be collected? > > Ruby's GC will eventually collect unreferenced objects without any > intervention on your part. It may not collect them on the first sweep, > but it will collect them. You can force GC to run earlier than normal by > calling GC.start, but that doesn't necessarily mean that every > unreferenced object will be collected on that sweep. > > In one of your earlier posts you said you were using a 3rd-party > library? Have you determined that it's not responsible for the memory > allocations? > > Have you determined that no references exist to objects that you think > should have been cleaned up? > > -- > RMagick: http://rmagick.rubyforge.org/ > RMagick 2: http://rmagick.rubyforge.org/rmagick2.html > > -- Joey Marino ------=_Part_1476_16954913.1206922026954--