JEP 132: More-prompt finalization
tony.printezis at oracle.com
Fri Jan 6 02:34:08 PST 2012
On 01/05/2012 09:41 PM, David Holmes wrote:
> On 6/01/2012 3:37 AM, Kirk Pepperdine wrote:
>> I get the feeling that what people are looking for is a destructor..
>> and in Java the destructor is close(). One has to consider finalization
>> of any resource to be the mechanism of last resort or when all else
>> fails, finalization will catch it (assuming it has a chance to run). Eg,
>> it's the application's responsibility to call close(). If you know
>> enough to call System.gc() (or any other API), you should know enough to
>> call close.
> Not to defend finalization
> in any way but the key difference is that any part of the code can
> call System.gc() or System.runFinalization() without needing to know
> what exactly needs to be finalized.
If each library could indicate to the GC whether the resource it manages
is running low or not, using the API I mentioned, the GC could do the
above automatically, behind the scenes, without the user having to do
> Afterall the key thing about GC is it relieves the programmer from
> having to manage object lifetimes, so if you don't know when the
> object is no longer used you don't know when to call close.
More information about the hotspot-dev