Reputation: 4831
I had window leak in my application activity which i fixed. But, when i tested the app using Memory Analyzer Tool in android - Histogram View, i find 2 instances of my activity.
.MATDemoActivity. | | |
com.pace.mat.MATDemoActivity | 2 | 368 |
Since there is no memory leak, how can it be 2 objects ? Kindly help me understand the data in MAT result .... Thanks in advance
Please find the complete code and the related discussion in this link.
=================
I found that when i start from Activity 1st -> 2nd -> 1st. Shallow Heap of 1st activity class = 2 and 2nd activity class = 1 and when i move from 1st -> 2nd -> 1st -> 2nd ... Shallow Heap of 1st activity class = 1 and 2nd activity class = 2.
So i tried with launch modes. i set android:launchMode="singleTask" for all activities. Now shallow heap for both the activities are equal to number of times i navigate to the page. But since multiple instances are not allowed in this launch mode, why am i not getting the shallow heap object count as 1 ?
Please share your ideas which would help me understand this better.
Upvotes: 2
Views: 964
Reputation: 4831
In android, we can use Memory Analyser tool to capture the memory leaks(if any) in a particular code. We should generate the heap dump just before performing the operation responsible for leak and after completing the operation. Compare these 2 dumps and find which objects are taking memory and why it is not garbage collected.
In my case mentioned above, i rather than analysing the dump generated after going to 2nd activity, i tried to compare the dumps before and after the activity. I got the required results clearly.
Also, regarding MAT tool, it is good to try more than once and compare the dumps and choose a dump for analysis.
Thanks friends.
Upvotes: 0