From: "Collins, Justin" Date: 2006-04-03T05:01:57+09:00 Subject: Re: (Static) Constructors/Destructors in Ruby ------_=_NextPart_001_01C65690.49FAC7D9 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To clarify, I was talking about Java. -Justin -----Original Message----- From: Mauricio Julio Fern=E1ndez Pradier on behalf of Mauricio Fernandez Sent: Sun 4/2/2006 4:31 AM To: ruby-talk ML Subject: Re: (Static) Constructors/Destructors in Ruby =20 On Sat, Apr 01, 2006 at 06:31:42AM +0900, Justin Collins wrote: > I believe this is the case if the garbage collector never runs. That = is,=20 > if the program exits before it is necessary. > Also, there are situations in which objects are never released, so the = > finalize method won't be called then, either. If I recall correctly. The finalizers will be run on exit ObjectSpace.define_finalizer(a =3D "", lambda{ puts "EXECUTED" }) END{ puts "leaving" } puts "hi" RUBY_VERSION # =3D> "1.8.4" # >> hi # >> leaving # >> EXECUTED But you can bypass them with Kernel#exit! batsman@tux-chan:~/mess/current$ cat exit_bang.rb=20 ObjectSpace.define_finalizer(a =3D "", lambda{ puts "EXECUTED" }) END{ puts "leaving" } puts "hi" puts RUBY_VERSION exit! batsman@tux-chan:~/mess/current$ ruby exit_bang.rb=20 hi 1.8.4 --=20 Mauricio Fernandez - http://eigenclass.org - singular Ruby ------_=_NextPart_001_01C65690.49FAC7D9--