Total Available memory for Memory Management logic
<p>I am having problem releasing memory. I have a <code>Hashmap</code> in which i am adding a <code>Bitmap</code> , and the no. of bitmaps is quite large. For this reason i am getting <code>OutOfMemoryError</code>. So for this i have decided to release <code>Bitmap</code> which is least used from <code>Collection</code>, on memory crunch or system getting low heap memory.</p>

<p>For getting current memory available i used "<strong>ActivityManager.MemoryInfo.availMem</strong>" but it gives total RAM size memory, not Available Heap memory. And i found that this <strong>memory is not getting updated on releasing</strong>  Bitmap from collection.</p>

<p>Then i have used these three method </p>

<pre><code>Debug.getNativeHeapAllocatedSize()
Debug.getNativeHeapFreeSize()
Debug.getNativeHeapSize()
</code></pre>

<p>but found the NativeHeapSize goes on increasing upto some certain say 16MB changing after that an <code>OutOfMemoryError</code> occur. In this also i found that the <code>NativeHeapAllocatedSize</code> and <code>getNativeHeapSize</code> not decreasing on releasing  <code>Bitmap</code> from <code>Collection</code>.</p>

<p>So please help me for solving the problem if anyone facing the same problem and fixed earlier it.</p>

<p>My problem is i want to calculate Max Available application memory allocated and currently available memory, for such that if currently available memory goes beyond the Threshold memory i will release some <code>Bitmap</code> from the collection and GC will reclaim the memory and free it without generating error.</p>
