开发者

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

开发者 https://www.devze.com 2023-03-22 18:57 出处:网络
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.

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 ac开发者_如何转开发tivity A.

Just to show that I'm using allocation tracker correctly:

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


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


I believe the Allocation Tracker is a log of items that have been allocated to memory (i.e. initialized). It is not a snapshot of items currently in memory. You need to look at the Heap for that.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号