Note that there are some explanatory texts on larger screens.

plurals
  1. POTotal available memory for memory management logic
    text
    copied!<p>I am having a problem releasing memory. I have a <code>Hashmap</code> in which I am adding a <code>Bitmap</code> , and the number 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 on heap memory.</p> <p>For getting the current memory available, I used "<strong>ActivityManager.MemoryInfo.availMem</strong>", but it gives the total RAM size memory, not available heap memory. And I found that this <strong>memory is not getting updated on releasing</strong> Bitmap from the collection.</p> <p>Then I have used these three methods:</p> <pre><code>Debug.getNativeHeapAllocatedSize() Debug.getNativeHeapFreeSize() Debug.getNativeHeapSize() </code></pre> <p>but I found the NativeHeapSize goes on increasing up to some certain level, say 16&nbsp;MB, changing after that an <code>OutOfMemoryError</code> occur. In this also, I found that the <code>NativeHeapAllocatedSize</code> and <code>getNativeHeapSize</code> is not decreasing on releasing <code>Bitmap</code> from <code>Collection</code>.</p> <p>How do I solve this problem?</p> <p>My problem is I want to calculate the maximum available application memory allocated and currently available memory, such that if the currently available memory goes beyond the threshold memory I will release some <code>Bitmap</code> from the collection and <a href="http://en.wikipedia.org/wiki/Garbage_collection_%28computer_science%29" rel="nofollow">garbage collection</a> will reclaim the memory and free it without generating an error.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload