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?
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.
"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".
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.
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.
For more details about your issue, look at the referent field of your Finalizer
. Finalizer objects are just extended Reference
s, 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With