Noel J. Bergman wrote:
and [Java] certainly does not guarantee that they will run
before Java decides to garbage collect that object.

I believe there is a guarantee that the finalize() method will be
called on an object before it is garbage collected

You mis-understood. Rephrasing, you cannot count on Java to call the finalize method if it has not has not yet decided to garbage collect the object.

I would explain it that you cannot guarantee when Java will decide to garbage collect /this/ object. Even an explicit call to System.gc() does:


"Calling the gc method suggests that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made a best effort to reclaim space from all discarded objects."

So just because you no longer reference it in your code will System.gc() get called. You could try to call System.runFinalization(). However I would suggest switching to an active way of cleaning up resources rather than relying on finalize().

--
Serge Knystautas
President
Lokitech >> software . strategy . design >> http://www.lokitech.com
p. 301.656.5501
e. [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to