Reputation: 3003
Hi iv'e read around on errors having to do with grow heap in android
08-13 21:46:22.382: I/dalvikvm-heap(10859): Grow heap (frag case) to 20.578MB for 2400016-byte allocation
Below is the log(filtered) where i repeatedly just back out of my application and start it again over and over again. As you can se the heap grows for for each restart. How can that be? Shouldn't the apps heap get cleared when completely exited?
If i make any change in the code and restart the application the heap resets to its original value. Is this behaviour normal?
The same heap growth also happens everytime i switch activities within my application. I programmed my app in andengine. I got the heap up to 80MB and loading got much slower with the bigger heapsize.
I/dalvikvm-heap(13094): Grow heap (frag case) to 13.198MB for 2400016-byte allocation
I/dalvikvm-heap(13094): Grow heap (frag case) to 13.354MB for 2400016-byte allocation
I/dalvikvm-heap(13094): Grow heap (frag case) to 13.350MB for 2400016-byte allocation
I/dalvikvm-heap(13094): Grow heap (frag case) to 13.350MB for 2400016-byte allocation
I/dalvikvm-heap(13094): Grow heap (frag case) to 13.406MB for 2400016-byte allocation
I/dalvikvm-heap(13094): Grow heap (frag case) to 13.268MB for 2400016-byte allocation
I/dalvikvm-heap(13094): Grow heap (frag case) to 13.265MB for 2400016-byte allocation
I/dalvikvm-heap(13094): Grow heap (frag case) to 13.264MB for 2400016-byte allocation
I/dalvikvm-heap(13094): Grow heap (frag case) to 14.818MB for 2400016-byte allocation
I/dalvikvm-heap(13094): Grow heap (frag case) to 14.814MB for 2400016-byte allocation
I/dalvikvm-heap(13094): Grow heap (frag case) to 14.813MB for 2400016-byte allocation
I/dalvikvm-heap(13094): Grow heap (frag case) to 14.813MB for 2400016-byte allocation
I/dalvikvm-heap(13094): Grow heap (frag case) to 16.421MB for 2400016-byte allocation
I/dalvikvm-heap(13094): Grow heap (frag case) to 16.427MB for 2400016-byte allocation
I/dalvikvm-heap(13094): Grow heap (frag case) to 16.426MB for 2400016-byte allocation
I/dalvikvm-heap(13094): Grow heap (frag case) to 16.426MB for 2400016-byte allocation
//**-Not A log message: here i simply changed a variables name and restarted**
I/dalvikvm-heap(13497): Grow heap (frag case) to 12.995MB for 2400016-byte allocation
I/dalvikvm-heap(13497): Grow heap (frag case) to 13.002MB for 2400016-byte allocation
I/dalvikvm-heap(13497): Grow heap (frag case) to 13.002MB for 2400016-byte allocation
I/dalvikvm-heap(13497): Grow heap (frag case) to 13.002MB for 2400016-byte allocation
It's like a memory leak that is retained after closing the app, in the app i do use sharedPreferences to save things. But i fail to see how that can have an effect here. Any ideas?
Upvotes: 0
Views: 2377
Reputation: 6895
Android applications don't simply close, see this nice blogpost on the topic: http://blog.radioactiveyak.com/2010/05/when-to-include-exit-button-in-android.html
The heap grows because your application does not close, it is just hidden. Still, it seems you do in fact have a memory leak. The heap shrinks when you change a variable name because a new apk is generated, your application on the phone gets killed and the application is reinstalled.
Upvotes: 1