Possible Memory leak through FinalizerReference

十年热恋 提交于 2019-12-30 17:23:15

问题


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




回答2:


There is likely no memory leak involving FinalizerReference in your app, although the Android Memory Profiler makes it look like there is.

My investigation of similar concerns convinced me that Profiler performs massive multiple counting of the same small amount of memory in the case of FinalizerReference, so that the reported value of Retained Memory is meaningless, and sometimes even ludicrous.

In your case, the ~38kB Shallow Size is important, but small, while the ~40 MB Retained Memory should be ignored.



来源:https://stackoverflow.com/questions/33666382/possible-memory-leak-through-finalizerreference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!