-1
Bitmap newImage = Bitmap.createBitmap(wid,hgt, Bitmap.Config.ARGB_8888);

This gives memory leak fatal exception when I use it in camera overlay second time for capturing image.Provide some code functionality why it occurs

rahultheOne
  • 152
  • 1
  • 8
  • possible duplicate of [java.lang.OutOfMemoryError: bitmap size exceeds VM budget - Android](http://stackoverflow.com/questions/1949066/java-lang-outofmemoryerror-bitmap-size-exceeds-vm-budget-android) – 2Dee Feb 19 '14 at 13:19

2 Answers2

1

I was facing similar issue. If you want to only display the Bitmap (not some operations related to size and quality), scaling down the image is best option. Moreover you are using ARGB_888 which takes 4 bytes to store each pixel, hence this issue occurs more often. You can use RGB_565 which takes 2 bytes to store 1 pixel. Make sure your are recycling your bitmap and assigning it to null after using. Calling System.gc() will reduce the occurrence of this issue.

Neha Nathani
  • 554
  • 4
  • 10
0

please refer this site (http://developer.android.com/training/displaying-bitmaps/index.html) you got how to use bitmap efficiently.