title: Heap size continuously increased when creating and deleting (recycling) Bitmaps in an ArrayList
body: <p>I am creating a application that stores bitmaps in an array list or in an array. I have set <code>android:largeHeap="true"</code> in the manifest to increase the memory size for the application. I am creating 20 bitmaps and after that if a new bitmap created the first bitmap is recycled (deleted) and new one will be added in the array list. Every time when I add an extra bitmap it releases the memory but after the next 15 to 20 (a total of more than 35) bitmap heap size increased about 20 to 25 MB. This process continues and an out of memory exception occurs. The space not released. I have tried each of the following individually and all together in sequence:</p>
  
  <ol>
  <li>recycle bitmap</li>
  <li>assign null</li>
  <li>remove from arraylist</li>
  </ol>
  
  <p>The problem is still there.</p>
  
  <pre><code>ArrayList&lt;Bitmap&gt; linesbitmap;
  
  private void touch_start(float x, float y) { // function called on every touch
      if (index &gt;= 19) {
          while (linesbitmap.size() &gt;= 19) {
              linesbitmap.get(0).recycle();
              linesbitmap.remove(0);
          }
          System.gc();
          System.runFinalization();
          System.gc();
      }
      if (mBitmap != null) {
          linesbitmap.add(Bitmap.createBitmap(mBitmap));
      }
      index = linesbitmap.size();
  }
  </code></pre>