title: App crashes with out of memory when capturing a photo in Cordova 3.0 app
body: <p>I am running a <strong>Phonegap (Cordova 3.0) app</strong> on my Android 2.3.6 Nexus One smartphone. My problem is that when I launch the camera and capture the image, after capture the app crashes and forced to be closed.</p>
  
  <p>I used logcat app to take a look at the logs and this is what I have:</p>
  
  <pre><code>02-15 13:07:04.515 E/dalvikvm-heap( 5678): 3840000-byte external allocation too large     for this process.
  02-15 13:07:04.555 E/GraphicsJNI( 5678): VM won't let us allocate 3840000 bytes
  02-15 13:07:04.555 D/dalvikvm( 5678): GC_FOR_MALLOC freed 0K, 56% free 3528K/8007K, external 21308K/23356K, paused 29ms
  02-15 13:07:04.555 D/AndroidRuntime( 5678): Shutting down VM
  02-15 13:07:04.555 W/dalvikvm( 5678): threadid=1: thread exiting with uncaught exception (group=0x40015560)
  02-15 13:07:04.555 E/AndroidRuntime( 5678): FATAL EXCEPTION: main
  02-15 13:07:04.555 E/AndroidRuntime( 5678): java.lang.OutOfMemoryError: bitmap size   exceeds VM budget
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at android.graphics.Bitmap.nativeCreate(Native Method)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at android.graphics.Bitmap.createBitmap(Bitmap.java:477)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at   android.graphics.Bitmap.createBitmap(Bitmap.java:444)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:349)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at org.apache.cordova.camera.CameraLauncher.getScaledBitmap(CameraLauncher.java:618)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at org.apache.cordova.camera.CameraLauncher.onActivityResult(CameraLauncher.java:346)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at org.apache.cordova.CordovaActivity.onActivityResult(CordovaActivity.java:915)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at android.app.Activity.dispatchActivityResult(Activity.java:3908)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at android.app.ActivityThread.deliverResults(ActivityThread.java:2528)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:2574)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at android.app.ActivityThread.access$2000(ActivityThread.java:117)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:961)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at android.os.Handler.dispatchMessage(Handler.java:99)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at android.os.Looper.loop(Looper.java:130)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at android.app.ActivityThread.main(ActivityThread.java:3683)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at java.lang.reflect.Method.invokeNative(Native Method)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at java.lang.reflect.Method.invoke(Method.java:507)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  02-15 13:07:04.555 E/AndroidRuntime( 5678):     at dalvik.system.NativeStart.main(Native Method)
  02-15 13:07:04.565 W/ActivityManager(  118):   Force finishing activity com.test.app/.TelerikCallbackActivity
  </code></pre>
  
  <p>From what I can understand from the log files is that there is not enough memory to profess the captures image.</p>
  
  <p>I am using <code>navigator.camera.getPicture</code> with <code>Camera.DestinationType.FILE_URI</code> to capture the photo and process it. I tried lowering the image quality to 20 from 50 and it didn't solve the problem.</p>
  
  <p>From the logs I can understand that the captured image from my Nexus One is around 3.7MB, although the JPEG captures is much smaller. </p>
  
  <p>The app didn't crash on other devices that I've tried it on, only on my Nexus One, but my Nexus one has the lowest specs compared to the other phones.</p>
  
  <p>I don't know how to solve this problem and need your help. Thanks.</p>
  
  <p><strong>Update</strong>: I lowered the resolution from 1600 pixels to 600 pixels (max for either width or height) and the camera captured the image successfully. However, I want to be able to capture a higher resolution on my Nexus One phone, at least 1600 pixels if it's possible in any way.</p>