I know this may seem impossible to determine without actual code but please bear with me. I think it's possible to determine something from the symptoms.
I have a hierarchy browser where each level of a hierarchy is displayed by its own activity. If you examine too many branches of the hierarchy, it will throw an OutOfMemoryError
exception. This sounds like a memory leak but a casual look at the code doesn't reveal anything obvious so I want some clarification on some aspects of Java and Android before I do a more thorough investigation.
First, can I rely on unused activities to be garbage collected before OutOfMemoryError
is thrown? I would consider it to be odd behavior if this were not the case but it would explain everything I'm encountering.
Secondly, can the Dalvik garbage collector collect circular references? I don't think I have any but if it can't, I'll know to look for that in my code.
I know there are way to leak memory in Android applications by creating references to things from places that live for the life of the program but, again, I don't think I'm doing that. For example, I haven't created any UI controls programatically, nor have I passed the current activity as a Context
to anything.
Finally, I've never noticed this bug before recently and the only thing that's changed since it was first created is that the Android version was upgraded from some flavor Jelly Bean to KitKat.
Any help would be greatly appreciated. Thank you!