From: Robert Klemme Date: 2008-08-01T17:34:10+09:00 Subject: Re: gc doesn't collect? On 1 Aug., 09:08, Eric Hodel wrote: > $ ruby -v final.rb > ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0] > 81660 created > avr > 81660 collected > 81660 finalized > $ ruby16 -v final.rb > ruby 1.6.8 (2005-09-21) [i386-darwin9.4.0] > 1117686 created > 1117686 finalized > omu > 1117686 collected > $ > > > It seems to only do finalizations when a user > > explicitly calls GC.start, or when the program terminates.  Is there a > > reason for this 'deferred_final_list' activity? > > This patch seems to restore 1.6 behavior: But does it also make finalization happen before program exit? (This was Roger's main point IIRC.) There was probably a good reason why the order was reversed namely to make sure that objects were gone before invoking their finalizers. Actually this is how it is defined, i.e. the finalizer is called after the object has vanished (see Pickaxe for example). > $ svn diff gc.c > Index: gc.c > =================================================================== > --- gc.c        (revision 18230) > +++ gc.c        (working copy) > @@ -1196,7 +1196,7 @@ gc_sweep() > >       /* clear finalization list */ >       if (final_list) { > -       deferred_final_list = final_list; > +       finalize_list(final_list); >         return; >       } >       free_unused_heaps(); Cheers robert