10 Reasons We Need Java 3.0
Subject:   Nuke finalizers?
Date:   2002-08-06 14:28:55
From:   bezdar
Have the finalizers _running at arbitrary time at the discretion of VM_ proven to be The Good Thing (TM)?

If their intent is to free resources (like close Network connections) their unpredictable in time invocation seems a misuse.

The major obstacle IMO is the following:
- imagine there are some unfinalized objects
- imagine that the VM gets into dire straits, it's in a Bad Need For Memory (and right now!)
- but to run the finalizer we need some active thread - we can't reclaim the memory right away, we need to run the finalizer first, but what if this process (running a finalizer) will need more memory itself (and we already have none!)

On the other hand, if the VM has had some time free and managed to have run the finalizer up to this point (what is a matter of chance) - then all goes well.

So we either get or not get an OutOfMemoryException depending on fortune and probably _low system load in previous minutes_.