title: Android heap growing when restarting application
body: <p>Hi iv'e read around on errors having to do with grow heap in android</p>
  
  <pre><code>08-13 21:46:22.382: I/dalvikvm-heap(10859): Grow heap (frag case) to 20.578MB for 2400016-byte allocation
  </code></pre>
  
  <p>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? </p>
  
  <p>If i make any change in the code and restart the application the heap resets to its original value. Is this behaviour normal?</p>
  
  <p>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. </p>
  
  <pre><code>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
  </code></pre>
  
  <p>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?</p>