Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible Memory leak through FinalizerReference

Tags:

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?

enter image description here

like image 932
amitooshacham Avatar asked Nov 12 '15 07:11

amitooshacham


People also ask

What could be the possible cause of memory leaks?

In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in a way that memory which is no longer needed is not released. A memory leak may also happen when an object is stored in memory but cannot be accessed by the running code.

Can a memory leak cause stack overflow?

"Memory leak", in brief, refers to the scenario that memory is allocated but not released even if it is no longer needed. A stack overflow itself is NOT causing any unneeded memory to fail to be released. There is no reason that you can treat a stack overflow as a "memory leak".

Can memory leak?

What is a memory leak? Despite having adequate RAM and not running resource-intensive software, there can be another situation where all available RAM gets used and performance degrades. This is known as a memory leak, and it happens when software fails to manage the available RAM correctly.

What is memory leak and out of memory?

A memory leak in Java is when objects you aren't using cannot be garbage collected because you still have a reference to them somewhere. An OutOfMemoryError is thrown when there is no memory left to allocate new objects.


1 Answers

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

like image 151
Kineolyan Avatar answered Sep 18 '22 14:09

Kineolyan