Hi,

I think that either I've stumbled onto a bug or I'm missing something
on how to manage my resources.  I have an activity with a Java based
view that contains 30 or so small images (~2k each .png) that are
loaded into an array when the view is created.  In "normal" operation,
everything runs fine.  When I flip the orientation between landscape
and portrait 3-4 times, I get the following:

E/AndroidRuntime(  472): java.lang.OutOfMemoryError: bitmap size
exceeds VM budget
E/AndroidRuntime(  472):        at
android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
E/AndroidRuntime(  472):        at
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:290)
E/AndroidRuntime(  472):        at
android.graphics.drawable.Drawable.createFromStream(Drawable.java:635)
E/AndroidRuntime(  472):        at
android.content.res.Resources.loadDrawable(Resources.java:1440)
E/AndroidRuntime(  472):        at
android.content.res.Resources.getDrawable(Resources.java:498)

When the orientation gets changed, the activity seems to go through
the entire lifecycle (pause, stop, then create again).  A new instance
of the activity's view is created in the onCreate method and it seems
that the pause/stop steps in the lifecycle don't clean up the old
view.  I've tried explicitly setting the reference to the view to null
in onPause and doing a System.gc(), but that doesn't seem to help.
I've also tried setting the requested orientation to portrait in hopes
that the activity would then ignore orientation changes, but that
didn't work either.  GC messages come up after every orientation
change so one would think that the garbage collector was doing its
job.

I could just leave this be and assume people aren't going to be
randomly flipping their phone open and closed while they're using my
app, but that seems pretty sloppy.  I'd like to know what's going on
here and fix it.

Any ideas?

Thanks,
Steve

--~--~---------~--~----~------------~-------~--~----~
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