I experience some memory leaks in my android application. I’ve already used MAT to analyze the memory usage. But I have one question from the DDMS perspectiv in Eclipse, what does 1-byte array[byte[], boolean[]) mean?
Is this specific for my application? You can see that this is the big memory leak issue, this always increases in size, and the rest will increase and decrease randomly. My guess is that the GC doesn’t catch this type. Can anybody explain why this happen, with this little information?
A
byteand abooleanare each 1 byte. If you have an array of those you have a “1-byte array”.A
ByteBufferfor example should internally hold one of those.You have a total of 614 of them where the smallest one be a
byte[24](orboolean[24]), the largest one is 3MB. All of them together use 104MB.The GC will get rid of them if they are no longer referenced.
For example when you put
in one of your classes and never set it back to null (
myArray = null) then this one can’t be garbage collected because another Object has a reference to it. The object would be the class itself (as inString.class). The class object can’t be garbage collected since classes are never unloaded. (they are referenced by theirClassLoaderwhich could itself be referenced / loaded by anotherClassLoaderand you can’t create Objects & use classes without them – they need to stay and they need to keep a reference to their classes)It’s usually not that simple but often start with
staticsomewhere.Within MAT (after you force GC) look at the reference chain for the objects that are no longer intended to stay alive and identify the one Object that holds the reference. Set that one to
nullin your code and your leak is gone. Explained in more detail here:http://android-developers.blogspot.de/2011/03/memory-analysis-for-android.html