title: Galaxy S3 memory leak using createBitmap in very simple code
body: <p>I have been trying to create a bitmap, create a canvas with that bitmap, and then pass it to my onDraw method in an imageView. During this process I noticed that the simple application was leaking memory and so reduced all possible code until I got what's shown below.</p>
  
  <pre><code>public class MainActivity extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          createImage(0,720,0,1280);
  
      }
  
      private void createImage(int l,int r,int t,int b){
  
          //Create the bitmap that will be used to draw on
          Bitmap.Config conf = Bitmap.Config.ARGB_8888; // see other conf types
          Bitmap bmp = Bitmap.createBitmap(r-l,b-t, conf); // this creates a MUTABLE bitmap
          bmp.recycle();
          bmp = null;
  
      }
  }
  </code></pre>
  
  <p>As can be seen, this code simply creates a bitmap and immediately nullifies it and recycles it.  Despite doing absolutely nothing with the bitmap, it leaks MainActivity on rotation change.  </p>
  
  <p>Now, how do I know it's leaking memory and not just a big image? Well, because I got many heap dumps in Eclipse and then looked at the MAT plug-in's histogram, and it kept saying there were always 2 instances of MainActivity around.  This is despite me waiting minutes to ensure that the system destroyed any copied objects from orientation change.</p>
  
  <p>This leak was happening on my T-Mobile Galaxy S3 (android 4.1.1) so I tried the exact same code on my Galaxy Tab 2 10.1" (4.2.2).  Oddly, the app did not leak on the tab.</p>
  
  <p>Here's my question, am I not using createBitmap correctly or is there a big bug in the S3 OS? </p>