In my application, user can click on a button and then he can select a
picture from his gallery.
This image is then displayed.

However, when the user performs 3 or 4 times this operation, the
following exception is thrown, due to memory allocation problem :


11-26 18:31:34.119: ERROR/dalvikvm-heap(707): 6291456-byte external
allocation too large for this process.
11-26 18:31:34.119: ERROR/(707): VM won't let us allocate 6291456
bytes
11-26 18:31:34.119: DEBUG/skia(707): xxxxxxxxxxxxxxxxxxxx
allocPixelRef failed
11-26 18:31:36.005: DEBUG/AndroidRuntime(707): Shutting down VM
11-26 18:31:36.005: WARN/dalvikvm(707): threadid=3: thread exiting
with uncaught exception (group=0x40013e28)
11-26 18:31:36.005: ERROR/AndroidRuntime(707): Uncaught handler:
thread main exiting due to uncaught exception
11-26 18:31:36.099: ERROR/AndroidRuntime(707):
java.lang.OutOfMemoryError: bitmap size exceeds VM budget
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:304)
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
android.graphics.drawable.Drawable.createFromStream(Drawable.java:635)
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
com.altran.test.selectpicture.MainActivity.onActivityResult
(MainActivity.java:74)
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
android.app.Activity.dispatchActivityResult(Activity.java:3415)
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
android.app.ActivityThread.deliverResults(ActivityThread.java:2835)
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
android.app.ActivityThread.handleSendResult(ActivityThread.java:2881)
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
android.app.ActivityThread.access$2300(ActivityThread.java:112)
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1608)
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
android.os.Handler.dispatchMessage(Handler.java:88)
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
android.os.Looper.loop(Looper.java:123)
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
android.app.ActivityThread.main(ActivityThread.java:3742)
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
java.lang.reflect.Method.invokeNative(Native Method)
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
java.lang.reflect.Method.invoke(Method.java:515)
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:739)
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
11-26 18:31:36.099: ERROR/AndroidRuntime(707):     at
dalvik.system.NativeStart.main(Native Method)



Here a sample of my code where problem is focused :

InputStream is = getContentResolver().openInputStream( currImageURI );
Drawable drawable = Drawable.createFromStream( is, "src" );
is.close();
m_imageView.setBackgroundDrawable( drawable );



Is it possible to force object (here the Drawable object) to be
released from memory ?

Thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to