[5898] in java-interest
Re: Finalize Broken?
daemon@ATHENA.MIT.EDU (Tim Lindholm)
Mon Mar 4 00:50:21 1996
Date: Sat, 2 Mar 1996 10:09:13 -0800
From: lindholm@scndprsn.eng.sun.com (Tim Lindholm)
To: java-interest@java.Eng.Sun.COM, mikea@ai.mit.edu, Jim.Graham@Eng.Sun.COM
Close, but no cigar...
You're right that unreferenced objects aren't immediately collected, and
that explicitly garbage collection will queue finalizable garbage objects
up for finalization. But the finalize methods of those objects are not
called synchronously by garbage collection, as Jim suggests. Finalization
is normally done asynchronously, by a low-priority daemon thread, so
just forcing GC may not be enough for Mike (the original writer) to see
the synchronous behavior he wants. You can force synchronously finaliza-
tion of all outstanding finalizable garbage objects by calling
System.runFinalization.
-- Tim
----- Begin Included Message -----
From daemon@java Tue Feb 20 21:07:54 1996
Date: Tue, 20 Feb 1996 15:22:36 -0800
To: java-interest@java.Eng.Sun.COM, mikea@ai.mit.edu
Subject: Re: Finalize Broken?
From: Jim.Graham@Eng
Sender: owner-java-interest@java
> Everytime the testing() method is run, a new tryer object is created.
> Therefore, when the method is done, it should be collected - thereby
> executing the finalize() method.
The finalize() method will be called the next time that Garbage Collection
is done. Unreferenced objects are not immediately collected. If you
put a call to "System.gc()" after each call to "testing()", then you
should see the finalizer getting called. If you put one call to System.gc()
at the end of the main() method, then you should see both finalizers called
together there...
...jim
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com
----- End Included Message -----
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com