I have two activities: A and B. Starting in A, I go to activity B. Then I call finish() on B and get back to A. Every time I repeat this process allocated memory is increased by 0.1 MB.
So I want to find out what's causing this leak. I have tried to use the allocation tracker by tracking allocated memory during the process just mentioned. Then when I press "Get Allocations" I get a long list of allocations. My question is: How do I read that list in order to find out what's causing my leak?
I have tried to solve this by releasing all resources in the onDestroy method of activity B and that helped a little bit. And also, I'm not allocating new memory in the onResume method of activity A.
Just to show that I'm using allocation tracker correctly:
To find a memory leak, look at how much RAM the system is using. The Resource Monitor in Windows can be used to accomplish this. In Windows 8.1 and Windows 10: To open the Run dialogue, press Windows+R, then type "resmon" and click OK.
Using Memory Profilers Memory profilers are tools that can monitor memory usage and help detect memory leaks in an application. Profilers can also help with analyzing how resources are allocated within an application, for example how much memory and CPU time is being used by each method.
The best approach to checking for the existence of a memory leak in your application is by looking at your RAM usage and investigating the total amount of memory been used versus the total amount available. Evidently, it is advisable to obtain snapshots of your memory's heap dump while in a production environment.
You should checkout this video, it explains memory leak finding in details and is just great :)
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