I am constantly struggling with detecting memory leaks. I think I have several memory leaks in my project circular review of progress .
One of my assumptions is that I have a memory leak in the FadeRunnable inner class. But honestly, I donβt know exactly how to find out if this is the source of the problem. Well, when I make a normal script and switch the orientation, I see an increase in memory usage, as shown below. And if I comment on the use of the FadeRunnable class, the steps will be smaller (but still there, so I think this is not the only leak)

As soon as I analyze a bunch of heaps, I see something. But actually I donβt know what the meanings mean. What I do is
- Orientation changes many times
- Open a bunch of heaps and sort it by "Saved Size"
- Now when I click on "CircularProgressView", I see 8 rows in the correct area. I guess this means that 8 instances of "CircularProgressView" have leaked and live somewhere like an orphan in memory.
It is right? If so, how can I find out in the dump information (I think, somewhere in the bottom panel) where this object is stored / held.

I would like a step-by-step explanation of how to find out if and what kind of object is leaking some kind of memory.
All suspicious representation code can be found in this class.
https://github.com/momentummodules/CircularProgressView/blob/master/circularprogressview/src/main/java/momentum/circularprogressview/CircularProgressView.java
But also do not hesitate to familiarize yourself with the complete project for a deeper understanding, and if you want to play with it.
Thanks in advance!
UPDATE
The code link above shows the fixed code for the mem-leaking inner class. The following snippet shows the source code for mem-leaking, which should never be used that way
public class CircularProgressView extends View { ... private Thread fadeThread = null; ... ... class FadeRunnable implements Runnable { @Override public void run() { ... } } ... ... private void startFade(boolean fadeIn) {
java performance android memory memory-leaks
martyn mlostekk
source share