From: Lars Christensen Date: 2001-08-12T20:11:22+09:00 Subject: [ruby-talk:19590] Re: Forced garbage collection On Sun, 12 Aug 2001, Nat Pryce wrote: > From: "Lars Christensen" > > I am testing some code that uses ObjectSpace#define_finalizer, but I can > > not force objects to be garbage collected using GC.start or > > ObjectSpace.garbace_collect. > > I've been having the same problem with Ruby 1.6.4. trying to implement > a weak hash. If my unit tests call ObjectSpace.garbage_collect or > GC.start, finalizers don't get called (I cannot tell if garbage collection > has > actually happened or not). When the program exists, finalizers do get > called. I tried adding a finalizer on a object from its own methods, i.e. ObjectSpace.define_finalizer(self) { puts 'finalized'; } The finalizer never gets called :(. Only if i do it externally to the object, it works: ObjectSpace.define_finalizer(someObject) { puts 'finalized'; } (bug report #163) Is the GC really that buggy or am I missing something? -- Lars Christensen, larsch@cs.auc.dk