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

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.

Of course, this normally makes the application to crash. I've put
catch (OutOfMemoryError e) around the method invocation. I know that
catching errors is unusual, but in JSE applications it proved to work
pretty good, especially when the problem was due to image manipulation
that consumed all the memory. The Android app seemed to survive for a
while, but then it blocked the computer. All buttons are irresponsive,
even though the phone seems still alive (e.g. it's playing the audio
notification that new email has been spotted). I tried holding the
power button, it triggered the shut down menu, but touching a menu
option didn't do anything. Only after a while, the phone became
responsive again.

Now, it's reasonable that one can't display everything on a
smartphone; I'm sure there's some inefficient memory management I'm
doing (perhaps keeping too many images in memory); ok, I have to
improve my code. Given that I'll do, how can I add some safety
facility to avoid the most severe consequences? Making an irresponsive
application it's a 100% sure way to make people to uninstall my app
and give bad reviews.

I'm thinking of a two-pronged safety approach: 1) whether it's
possible to understand in advance whether an image is too large to be
rendered by itself; 2) whether it's possible to recover from an OOM in
any case.

Thanks.

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

iEYEARECAAYFAkySa8cACgkQeDweFqgUGxd0WACgqxeDnLvof8nnry2YN6spYXy6
Ga8An0CujetPySu44VsNJsAyL+BIpz1S
=cQIf
-----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 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