I'm trying to learn how to identify and treat memory leaks in my App. I'm reading this great article, but I'm a bit confused about how to apply that in the new "Android Profiler" tool, that came with Android Studio 3.0.
I'have a test application and LeakCanary is pointing that my App has memory leaks.
In fact, when I run the profiler and press "dump java heap" I can see that there are 4 instances of my MyCollectionActivity and, when I click on these instances, I can see the details:
But the tool that is shown in the article has options I cannot see in the "Android Profiler":
I will not go into depth about how to navigate the huge memory heap. Instead I’ll direct your attention to the Analyzer Tasks in the upper right corner of the screenshot below. All you have to do to detect the memory leak introduced in the example above is to check Detect Leaked Activities and then press play to get the leaked activity to show up under Analysis Results.
Where, in the new tool, is, for example, this "Analyzer Tasks" and "Analysis Results" that shows instances that have leaks?
If we select the leaked activity we are presented with a Reference Tree where the reference that is keeping the activity alive can be identified. By looking for instances with depth zero we find that the instance mListener located within the location manager is the reason our activity can’t be garbage collected.
That Android Profiler's image doesn't show that Reference Tree too, it shows the reference, but it doesn't seem to be very useful.
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