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:
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!