title: How to know that Canvas has used bitmap object
body: <p>Hi I am creating Bitmap object and using in canvas, like below code</p>
  
  <pre><code>Bitmap result = Bitmap.createBitmap(loadedImage.getWidth(), loadedImage.getHeight(), Config.ARGB_8888);
  Canvas mCanvas = new Canvas(result);    
  Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
  paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
  mCanvas.drawBitmap(blurBitmap, 0, 0, null);
  mCanvas.drawBitmap(loadedImage, 0, 0, paint);
  paint.setXfermode(null);
  
  ivBlur.setImageBitmap(result);
  
  // now i don't want Bitmap "result" so I am recycling it    
  if (result != null &amp;&amp; !result.isRecycled())
      result.recycle();
  }
  </code></pre>
  
  <p>But from above code I am getting an error like</p>
  
  <p><strong>trying to use recycled bitmap android</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/31216593/how-to-fix-canvas-trying-to-use-a-recycled-bitmap-error">How to fix &quot;canvas: trying to use a recycled bitmap error&quot;?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/14136026/trying-to-use-a-recycled-bitmap-android-graphics-bitmap">trying to use a recycled bitmap android.graphics.Bitmap</a></p>
  
  <p><a href="https://stackoverflow.com/questions/22129420/canvas-trying-to-use-a-recycled-bitmap-android-graphics-bitmap-in-android">Canvas: trying to use a recycled bitmap android.graphics.Bitmap in android</a></p>
  
  <p>If I don't write last three lines it is working perfect,
  It may be because Canvas is using Bitmap "result" object and I am recycling "result"</p>
  
  <p>Because of this bitmap is taking huge space, I have to recycle this bitmap otherwise I will get </p>
  
  <p><strong>java.lang.OutofMemoryError: bitmap size exceeds VM budget.</strong></p>
  
  <p>So does anyone know how can I get that, "Canvas has used bitmap object and now I can recycle result object". </p>