title: Java memory allocation workaround
body: <p>I'm trying to write a program for the Android platform where I deal with images a lot.
  Consider the following:</p>
  
  <pre><code>Bitmap b = BitmapFactory.decodeFile(File imagePath) // 5mb picture is stored into memory as with 32bits of memory per pixel --&gt; almost run out of memory
  </code></pre>
  
  <p>I will want to change the pixels in this Bitmap, but for some reason the Bitmap returned is immutable. I figured that making a copy of it using b.copy(Config config, boolean isMutable)
  would do the trick, although I run into a RuntimeExeception saying that the VM won't let us allocate blah blah bytes of memory.
  My question is, would the following line</p>
  
  <pre><code>Bitmap mutable = BitmapFactory.decodeFile(File imagePath).copy(config, true);
  </code></pre>
  
  <p>allocate less memory and therefore be safely used to get my mutable copy of the Bitmap, given that there is no reference to the original immutable Bitmap?
  This seems to do the job sometimes, but I would like an explanation of whether I'm just talking nonsense or if what I'm doing is a clever workaround to achieve my task. </p>