-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 9/16/10 21:11 , Fabrizio Giudici wrote:
>
> My app, among other things, downloads and displays images from the
> Internet. Some might be too large and trigge an OOM when
> ImageView.setImage() is called.
>
For the record, the worse OOM (the one which crashes the phone) is one
that I haven't caught, as it originates from the event loop (see below).
In particular, it seems that ImageView.onMeasure() causes the whole
decoding of the image. It sounds strange, as I presume that
onMeasure() only needs the image dimensions, and it should be possible
to retrieve them *without* decoding the bitmap.

In any case, I'm now going to try subclassing ImageView and put a
catch (OOM) around that onMeasure(). Any other idea?


E/AndroidRuntime(15277): java.lang.OutOfMemoryError: bitmap size
exceeds VM budget
E/AndroidRuntime(15277):     at
android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
E/AndroidRuntime(15277):     at
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:459)
E/AndroidRuntime(15277):     at
android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:271)
E/AndroidRuntime(15277):     at
android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:296)
E/AndroidRuntime(15277):     at
android.graphics.drawable.Drawable.createFromPath(Drawable.java:801)
E/AndroidRuntime(15277):     at
android.widget.ImageView.resolveUri(ImageView.java:501)
E/AndroidRuntime(15277):     at
android.widget.ImageView.onMeasure(ImageView.java:577)
E/AndroidRuntime(15277):     at android.view.View.measure(View.java:7964)
E/AndroidRuntime(15277):     at
android.widget.Gallery.setUpChild(Gallery.java:786)
E/AndroidRuntime(15277):     at
android.widget.Gallery.makeAndAddView(Gallery.java:738)
E/AndroidRuntime(15277):     at
android.widget.Gallery.fillToGalleryRight(Gallery.java:697)
E/AndroidRuntime(15277):     at
android.widget.Gallery.layout(Gallery.java:628)
E/AndroidRuntime(15277):     at
android.widget.Gallery.onLayout(Gallery.java:336)
E/AndroidRuntime(15277):     at android.view.View.layout(View.java:6830)
E/AndroidRuntime(15277):     at
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119)
E/AndroidRuntime(15277):     at
android.widget.LinearLayout.layoutVertical(LinearLayout.java:998)
E/AndroidRuntime(15277):     at
android.widget.LinearLayout.onLayout(LinearLayout.java:918)
E/AndroidRuntime(15277):     at android.view.View.layout(View.java:6830)
E/AndroidRuntime(15277):     at
android.widget.FrameLayout.onLayout(FrameLayout.java:333)
E/AndroidRuntime(15277):     at android.view.View.layout(View.java:6830)
E/AndroidRuntime(15277):     at
android.widget.FrameLayout.onLayout(FrameLayout.java:333)
E/AndroidRuntime(15277):     at android.view.View.layout(View.java:6830)
E/AndroidRuntime(15277):     at
android.widget.FrameLayout.onLayout(FrameLayout.java:333)
E/AndroidRuntime(15277):     at android.view.View.layout(View.java:6830)
E/AndroidRuntime(15277):     at
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119)
E/AndroidRuntime(15277):     at
android.widget.LinearLayout.layoutVertical(LinearLayout.java:998)
E/AndroidRuntime(15277):     at
android.widget.LinearLayout.onLayout(LinearLayout.java:918)
E/AndroidRuntime(15277):     at android.view.View.layout(View.java:6830)
E/AndroidRuntime(15277):     at
android.widget.FrameLayout.onLayout(FrameLayout.java:333)
E/AndroidRuntime(15277):     at android.view.View.layout(View.java:6830)
E/AndroidRuntime(15277):     at
android.widget.FrameLayout.onLayout(FrameLayout.java:333)
E/AndroidRuntime(15277):     at android.view.View.layout(View.java:6830)
E/AndroidRuntime(15277):     at
android.widget.FrameLayout.onLayout(FrameLayout.java:333)
E/AndroidRuntime(15277):     at android.view.View.layout(View.java:6830)
E/AndroidRuntime(15277):     at
android.view.ViewRoot.performTraversals(ViewRoot.java:996)
E/AndroidRuntime(15277):     at
android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
E/AndroidRuntime(15277):     at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(15277):     at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(15277):     at
android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime(15277):     at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(15277):     at
java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(15277):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime(15277):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime(15277):     at dalvik.system.NativeStart.main(Native
Method)


- -- 
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
java.net/blog/fabriziogiudici - www.tidalwave.it/people
[email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkySbaIACgkQeDweFqgUGxcwPACeIgLb1iT3jLcQg+j+dTFEe5k4
k1QAn0lnnQzE65EDFVhcE5Ua+bvqpCPd
=Oho3
-----END PGP SIGNATURE-----

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

Reply via email to