Possible Memory leak through FinalizerReference

2019-02-21 10:37发布

问题:

I have a small android app and I tried looking for memory leaks, so I clicked 'Dump Java Heap' and the first class on the list is FinalizerReference (java.lang.ref). It has over 500 instances, each one with a 'next' and 'prev' to another FinalizerReference.

I know that FinalizerReference comes from objects that implement Object.finalize(), but I don't have an object in my app that implements it. How can I find out why this leak happens and fix it?

回答1:

For more details about your issue, look at the referent field of your Finalizer. Finalizer objects are just extended References, so you could investigate the content. It will give you information about the finalizing objects.

Depending on the content, you will have new leads. It is possible that the finalization process for the pending objects is very long. As you have only one thread processing them all, you may be somehow finalizing more than you can.

Cheers