Yeah, we've had a similar issue before. One thing you can try is to call
recycle() on the last frame of your animation before you replace it. This is
normally called by the garbage collector and works fine when you're not
close to the memory limit, but it sounds like there might be cases where you
temporarily go over the limit and the GC doesn't get to the bitmaps in time.

Matt

On Wed, Nov 25, 2009 at 2:37 PM, Matt Kanninen <mathias...@gmail.com> wrote:

> Matt,
>
> So in this case I definitely am frequently loading and unloading small
> images.  Those 10 id's all point at different states in our
> animation.  I can reduce the quality of our animation by reducing the
> views, and decrease how often I stumble down this cow path:
>
> but I only posted this stack trace because it was new, this happens
> anytime my app is run for more then half an hour, or 5 mins on the
> droid.  The droid uses the same apk, same images, and 2 slightly
> different xmls (we added margins to our Droid xml).
>
>
> http://groups.google.com/group/android-developers/browse_thread/thread/b455c6ac5782b7e7/c481a210b0f3c63d
>
> or to quote myself:
> "
> If my app runs for more then half an hour on the G1 it will fail on
> inflating views from xml, giving an error about insufficient memory
> creating a bitmap.  Another issue, which may be a side effect is that
> global static strings that are assigned at startup become null.
>
> I have worked around that by throwing up setters around those statics
> that also store them as a private preference, and thrown up getters
> that read the preference in case of null.
>
> The root cause of all of my issues may be that when I call release on
> my MediaRecorder it sometimes hangs.  No crash it just never returns,
> stalling the thread.  I have worked around that by calling release in
> a thread that only does that.
>
> Is anyone else seeing and working around issues like these? I could
> use some advice.
> "
>
> -Matt K
>
>
> On Nov 25, 10:07 am, Matt Hall <matt.h...@gmail.com> wrote:
> > How big (dimensions) are the graphics Matt? If they're not very big
> > then I'm guessing you have bitmap memory used elsewhere in the app
> > that's putting you close to the max. Bitmap memory is different than
> > your heap memory, so it's management is hidden from you a little more
> > but basically this error means you have too many graphics loaded at
> > once, or are unloading and loading a lot of graphics in a row so the
> > finalizer can't reclaim the bitmap memory in time.
> >
> > Matt
> >
> > On Nov 25, 12:46 pm, Matt Kanninen <mathias...@gmail.com> wrote:
> >
> > > <a href="http://code.google.com/p/android/issues/detail?id=5045";>Issue
> > > 5045</a>
> >
> > >http://code.google.com/p/android/issues/detail?id=5045
> >
> > > On Nov 25, 9:37 am, Matt Kanninen <mathias...@gmail.com> wrote:
> >
> > > > This:
> > > >         private static final int[] glowDrawableIds={
> > > >                 R.drawable.graphic_microphoneglow_01,
> > > >                 R.drawable.graphic_microphoneglow_02,
> > > >                 R.drawable.graphic_microphoneglow_03,
> > > >                 R.drawable.graphic_microphoneglow_04,
> > > >                 R.drawable.graphic_microphoneglow_05,
> > > >                 R.drawable.graphic_microphoneglow_06,
> > > >                 R.drawable.graphic_microphoneglow_07,
> > > >                 R.drawable.graphic_microphoneglow_08,
> > > >                 R.drawable.graphic_microphoneglow_09,
> > > >                 R.drawable.graphic_microphoneglow_10
> > > >         };
> > > > ...
> > > > View glow = findViewById(R.id.glow);
> > > > ..
> >
> > > > glow.setBackgroundResource(glowDrawableIds[scale]);
> >
> > > > is causing
> >
> > > > 11-25 09:21:02.046: WARN/UsageStats(1018): Failed to persist new
> stats
> > > > 11-25 09:21:02.694: DEBUG/dalvikvm(2386): GC freed 298 objects /
> 15656
> > > > bytes in 61ms
> > > > 11-25 09:21:02.952: ERROR/dalvikvm-heap(2386): 1111680-byte external
> > > > allocation too large for this process.
> > > > 11-25 09:21:02.952: ERROR/(2386): VM won't let us allocate 1111680
> > > > bytes
> > > > 11-25 09:21:02.952: DEBUG/AndroidRuntime(2386): Shutting down VM
> > > > 11-25 09:21:02.952: WARN/dalvikvm(2386): threadid=3: thread exiting
> > > > with uncaught exception (group=0x4001b180)
> > > > 11-25 09:21:02.952: ERROR/AndroidRuntime(2386): Uncaught handler:
> > > > thread main exiting due to uncaught exception
> > > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):
> > > > java.lang.OutOfMemoryError: bitmap size exceeds VM budget
> > > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> > > > android.graphics.Bitmap.nativeCreate(Native Method)
> > > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> > > > android.graphics.Bitmap.createBitmap(Bitmap.java:468)
> > > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> > > > android.graphics.Bitmap.createBitmap(Bitmap.java:435)
> > > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> > > > android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
> > > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> > > > android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
> > > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> > > > android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
> > > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> > > >
> android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:
> > > > 323)
> > > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> > > > android.graphics.drawable.Drawable.createFromResourceStream
> > > > (Drawable.java:697)
> > > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> > > > android.content.res.Resources.loadDrawable(Resources.java:1705)
> > > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> > > > android.content.res.Resources.getDrawable(Resources.java:580)
> > > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> > > > android.view.View.setBackgroundResource(View.java:7187)
> >
> >
>
> --
> 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<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

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