On Tue, 5 Jan 1999, nagendra mishr wrote:

> I've put in checks in our code to check is things are getting finalized... It does
> happen (eventually)
> 
> To force cleanups, I rely on the following:
> 
> 1.    add a void kill()   in all heavy classes.  make it  delete files, close
> sockets... etc.
Is this differen from what finalize() should do?
> 
> 2.    In void finalize()  I make all references point to null
> 
> One thing to note and this helps tremendously is to do a v.removeAllElements() for
> vectors not in use.   I think that should be added to the finalize section for
> Vector but that's up to SUN to do that.

Neither of these is relevant to the code I posted.

> 
> 3.    Don't forget to do a super.finalize() in all subclasses at the last line in
> void finalize()
Again, not relevant to the code I posted (but generally the Right Thing to
Do).
> 
> 
> The way I look at it, clean up the reference tree all you can so that the GC does
> not have to do it for you.  If the GC's work is less, it makes your code run
> faster since the GC is not sitting in its tree cleaning mechanism.
> 
> One other thing to note is the GC only runs when the system is idle.. It can be
> scheduled, but when it runs, it can get preempted pretty easily.. So if you
> specifically set things to null as much as you can, the GC's job will be easier
> and you'll reach all those hard to reach places faster.


The docs I have assert that in the code I posted, finalizer() should be
run.
> >
> > Bug Id 4148454 (State Closed, not a bug)
> >
> > "The System.runFinalization method can only invoke the finalize methods of
> > objects that that garbage collector has detected as being "finalizer
> > reachable." Unfortunately, the conservative GC in the "classic" VM sometimes
> > can't classify an object that way because there's a stray pointer to it
> > somewhere in a native stack. This is most likely what is happening in the
> > submitter's case; it works in JDK 1.1.5 out of sheer luck. The only way to
> > guarantee that you've dropped all references to an object is to ensure that
> > all threads that have ever referenced the object have terminated."

In my case, I had nulled the references. Can't see that there should be
anything on the stack: if ever it worked, it should work in the code I
posted.



-- 
Cheers
John Summerfield
http://os2.ami.com.au/os2/ for OS/2 support.
Configuration, networking, combined IBM ftpsites index.

Reply via email to