title: Out of memory errors occur with a high heap size but low allocated size. Why?
body: <p>I have a fairly memory intensive process that can cause the heap size to grow near its limits (like 24 in this case).</p>
  
  <p>However, when that process ends, and the Allocated memory (as listed in the DDMS Heap tool and in a heap dump) is far far lower like 6 or 7.</p>
  
  <p>Despite the Allocated memory being low, and there being a lot of free memory, the heap doesn't seem to come back down.</p>
  
  <p>So even though it says there is plenty of memory available I can still get out of memory errors in this case.</p>
  
  <p>So it begs a couple questions:</p>
  
  <ol>
  <li><p>Even though the Allocated memory in the Heap tab of DDMS and the heap dumps themselves only show 7mb of memory as allocated is there hidden memory that is not mentioned that is not being garbage collected?  If so, how do I track this down?</p></li>
  <li><p>It seems out of memory errors are based on heap size, not allocated memory size.  So is there a way to force the heap size to come back down when it doesn't need to be so high when the memory intensive process is over?</p></li>
  </ol>
  
  <p>Thanks for your insights.</p>