[gclist] Finalization releasing resources
27 Mar 1997 19:52:12 -0000
>>>>> "Giuliano" == Giuliano Carlini <GCARLINI@us.oracle.com> writes:
> "John D. Mitchell" <firstname.lastname@example.org> said: It is Bad Practice(tm) to rely
> on finalization for reclaiming resources which are heavily contended for
> (file handles) or otherwise where timeliness is important (e.g.,
> Why do you say this?
Because the "guarantees" given by the official *specification* of Java make
relying on finalization for "reclaiming resources which are heavily
contended for (file handles) or otherwise where timeliness is important
(e.g., sockets)" gross negligence, IMHO. You *cannot* rely on finalization
*ever* happening. You *cannot* relying GC *ever* happening. Yes, this is
a quality of implementation issue but do you want robust, portable code or
I never said that I agree with the choices that the Java folks made.
Wasn't it also on this very list where there was lengthy, heated discussion
about using finalizers for constrained resources?
> Why is releasing a socket quickly important? How does this place
> additional constraints on a system which releases sockets by invoking a
> finalizer on reclaim beyond those on a system using explicit release? Is
> it once more an issue of scarcity?
Hmm... If I'm writing a Java-based web server, it's awfully important that
the socket created for each response be terminated and made available. If
finalization never runs, the web server becomes useless and the kernel
becomes a wee bit overwhelmed by all of those sockets' resources.
Hope this helps,