From: Saynatkari Date: 2005-04-13T03:12:33+09:00 Subject: Re: ability to run finalizers at a given point of a program? Guillaume Cottenceau wrote: > Hi, > > I'm considering the possibility to run the finalizers at a given point > of a program. I have written the following program, and I'm > experiencing the following unexpected behaviour: I call GC.start in > the hope that finalizers of unscoped objects that have one will be > run, but it seems they aren't. If you really want to somehow 'delete' the objects (rather than just free some memory) at a certain point, you might want to use ensure. It works 'outside' exception handling, too. def foo() # Something ensure # Finalize end > http://www.zarb.org/~gc/t/prog/destructor/nodestructor.rb > > I have written the following program in ocaml, which has a closer GC > implementation than perl or python (these have reference counting, > ocaml doesn't) and it seems that contrary to Ruby, finalizers are run > as expected when a GC run is forced (however, when the closure used as > finalizer has a reference to anything inside the object, this counts > as a reference thus object is always scoped, so this is not really > useful as a finalizer/destructor anyway). > > http://www.zarb.org/~gc/t/prog/destructor/destructor.ml > > Do you guys have any insight with ruby behaviour? I use 1.8.2 on Linux. E