JEP 132: More-prompt finalization
david.holmes at oracle.com
Fri Jan 6 03:14:47 PST 2012
On 6/01/2012 8:34 PM, Tony Printezis wrote:
> 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
> anything else.
I'm not sure a library writer has the necessary information to do this.
Seems to me that how an application uses a particular type determines
the scarcity of the resource. I can imagine something like:
void setFinalizationLimit(Class<?> cls, int limit)
so that GC runs finalization once a "reference count" reaches "limit".
That limits the frequency of finalization, but the actual finalization
cost may still be unacceptably high.
>> 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