On Jun 6, 2015, at 11:02 AM, Peter Levart <peter.lev...@gmail.com> wrote: > > I understand that it would be desirable for a finalizable object to be made > "untracked" as soon as it is manually cleaned-up. This would most certainly > give a relief to GC as it could reclaim such untracked objects immediately > like normal objects without pushing them through all the finalization steps. > > Such feature would need new API. Here's my take on such API incorporated in > my prototype. This feature is mostly independent of other changes in the > prototype and could be provided stand-alone. I choose to incorporate it into > the prototype to compare it's overhead with classical finalization in > unchanged and changed JDKs: > > > http://cr.openjdk.java.net/~plevart/misc/JEP132/ReferenceHandling/webrev.03/
While changes are needed to do this sort of thing, it seems to me a better change would be to not use finalize() at all, but instead use PhantomReference-based cleanup. It provides exactly that kind of behavior, and has other benefits besides. There is some discussion about doing exactly that for File{Input,Output}Stream (see https://bugs.openjdk.java.net/browse/JDK-8080225).