On Mon, 15 Oct 2001, Aristarkh A Zagorodnikov wrote: > Hello! > Is there a way to force GC to reclaim _all_ unused objects > (disregarding time which it may take). I'm trying to create a > long-running application (some sort of data server), and it slowly > increases in size (gets 20 megs from initial 2.9 megs after several > hours of hard load) while ObjectSpace iterators does not indicate any > object growth. Quick'n'dirty hacks even at C source level are accepted > ;)) If there is any moment at which the process size gets at 20 megs, it is likely that it will stay at that size, unless you have very large Arrays/Hashes/Strings (usually 128 kilobytes), which get allocated separately by GLIBC (last time I checked), and thus reduce the process size. If the increase is really gradual while the amount of data stays low, this may indicate a memory-leak in one of the libraries you use. Or else, there may be an Array or Hash that you store lots of non-allocated objects in (Fixnum, Symbol), which don't show up in ObjectSpace. You may try something like this: ObjectSpace.each_object {|x| case x when Array,Hash,String puts "#{x.id} length=#{x.length}" if x.length > 1000 end } However, if a large array loses elements, it seems that its capacity shrinks (to length*2) only when length*10<capacity; i don't know about the others. ________________________________________________________________ Mathieu Bouchard http://hostname.2y.net/~matju