0

So I've been investigating an out of memory error in my droid app for a few days. I have used the android device monitor to keep track of heap size and I've even used MAT to check out heap dumps, but I think I need some help or a push in the right direction. I learned memory management in C on embedded systems, when it was all the developers responsibility, so I'm still learning about Java's garbage collection.

I would imagine my problem has to do with image (ParseImage) heavy views. Looking at the heap dump, I imagine that the byte arrays are the culprits and that's how images are stored by Android correct? The problem is, I'm not exactly sure the best way to clean up after images, especially since my images are all ParseImages. Additionally, I don't know exactly what it is that the garbage collector is missing or why or when. All I can see is that as I navigate from view to view in the application, the heap just keeps getting data allocated and never appears to release. This is apparent not only in the device monitor but also in the "Memory" portion of the toolbar in android studio.

Here is a screen cap of my heap dump in the memory analyzer:

enter image description here

You can see that the byte arrays are huge in the heap. I know I instantiate a lot of ParseImages, but I assumed the GC just cleaned them up. It seems like I might have to clean up the views myself. I have been looking at the Android developer docs and I'm still struggling, so if you have any advice on managing images or java memory management in general, it would be much appreciated! Thanks!

ThePartyTurtle
  • 2,276
  • 2
  • 18
  • 32
  • I'll check that out! – ThePartyTurtle Jun 09 '15 at 21:55
  • we're going to need more info on your implementation. How are you creating these `ParseImageViews`? – Sam Dozor Jun 09 '15 at 22:48
  • Hey Sam, so I figured out my problem. Those are images that are clobbering my heap, but the problem isn't the images themselves. It actually has to do with how I manage the activity lifecycle. I've just been creating new instances of activities rather than restarting existing instances. For example, my app has timeline and profile activities, and when users navigate from one to the other, new activities are being started rather than old ones being restarted. All the old activity view data and stuff gets left in memory. If this question needs to be closed or anything then that's cool. – ThePartyTurtle Jun 10 '15 at 16:18

0 Answers0