Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allocation Tracker: How to use it to detect memory leaks?

Tags:

android

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:

enter image description here

like image 531
Emir Kuljanin Avatar asked Jul 24 '11 16:07

Emir Kuljanin


People also ask

How do you detect memory leaks?

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.

Which analysis is used to detect memory leak?

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.

How do you detect memory leaks in performance testing?

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.


1 Answers

You should checkout this video, it explains memory leak finding in details and is just great :)

like image 194
dimsuz Avatar answered Oct 20 '22 12:10

dimsuz