0

I'm trying to trace memory leaks in my app. I have an Activity in which I can switch between 7 Fragments. I'm instantiating the Fragments in the Activity's onCreate() and using the same instances when switching between them.

I'm using Picasso to load any images in the Fragments. As I switch between the Fragments, the memory allocation keeps increasing and even on finishing the Activity, the memory is not freed.

I've used MAT to analyze the heap dump and it seems it's the Bitmaps that aren't being freed.

I understand that I have a leak in the Activity that contains the Fragments but since the the memory isn't being freed even after exiting the Activity, I guess I'm also holding onto the Activity also.

Since I haven't been able to use MAT in a beneficent way to identify the leaks (neither figure out where I'm holding onto the Activity), I'd appreciate if someone could help me out.

timemanx
  • 4,493
  • 6
  • 34
  • 43
  • do you _recycle()_ the bitmaps? – 18446744073709551615 May 06 '15 at 14:27
  • hmm lets do this, if you can post the Mat stats or you can post some codes in respect to how you close the activities, how you persist the fragment and whether you hold static bitmaps or static variables and also are you sure `onDestroy()` is always called on all 7+1 classes? get specific SIr – Elltz May 06 '15 at 16:32

0 Answers0