Hi Milan,
On 03/20/2017 02:13 PM, Milan Mimica wrote:
Hello
Hope you can help me with an advice.
I'm using a library, namely spring-jdbc, which implements
java.lang.Object.finalize() in one static inner class which does get
instantiated *a lot*. It creates significant contention on synchronized block
in java.lang.ref.Finalizer from Object's constructor. Are there any plans to
improve this (except from removing it)? I can see it's not trivial, but maybe
it could be reimplemented lock-free?
There were past attempts in this area (using concurrent doubly linked
list similar to the one in java.util.concurrent.ConcurrentLinkedDeque)
that did improve the contention a bit. Another drag is also the fact
that the Finalizer.register() method that must be invoked from VM as
part of object construction prevents certain optimizations in VM that
non-finalizable object constructors enjoy.
So the most productive way would be to ask Spring developers to remove
finalization and instead employ their own PhantomReference based cleanup
and/or adopt new JDK 9 Cleaner API when time comes...
Regards, Peter