Java doesn't release objects with finalize () completion

My application uses a third-party library (JTDS driver), in which there are some objects that override the finalize () method. I think that they obey all the rules about when not to use finalize()- it does not depend on whether they work on time or in general.

The problem is that objects are never released. They seem to get stuck in the Finalizer queue and are never deleted. They grow slowly over several weeks and run the JVM from the heap. Thread dumps show a Finalizer thread waiting for something to call finalize()on. If I call System.runFinalization(), the objects will be finalized and correctly removed from the finalizer queue (and will no longer appear in heap heaps).

Why System.runFinalization()does it delete objects correctly, but the Finalizer thread will not do it on its own?

+4
source share
3 answers

We had the same problem today. You do not indicate which JVM you are using, but just in case it is OpenJDK - there is an error https://lists.launchpad.net/openjdk/msg10021.html They say that it has already been fixed, so you just need to update it.

+1
source

This means that your finalize () methods take too long to create objects in the queue waiting for a call.

Objects are removed from the queue because they are called and will not be in the queue after the call.

0
source

Finalizer ?

: - , . - . .

, . , , , ? . , , .

" Java":

,

- ,

http://www.informit.com/articles/article.aspx?p=1216151&seqNum=7

0

Source: https://habr.com/ru/post/1531576/


All Articles