Also it is really poor design to be calling SurfaceView.onDraw() like this.
 The SurfaceView is part of the window it is attached to, and its onDraw()
is drawn to there.  Put your drawing code somewhere else, at least on a
different method.

On Sat, Feb 26, 2011 at 2:21 AM, seanw <[email protected]> wrote:

> Hi,
>
> The problem is you're creating a new bitmap every time onDraw is called. As
> your app can only typically allocate about 16Mb or 24Mb in total in Java,
> you're going to run out of memory quickly if the onDraw method gets called
> often. I'm not sure why the set of bitmaps aren't being garbage collected
> here but, even if they were, your app will suffer from stuttering being
> caused by the GC with this approach.
>
> What you should do is create the bitmap once somewhere else and then reuse
> this single bitmap object in your onDraw method. Related to this, make sure
> to call .recycle() on any bitmap object you're finished with to indicate
> that the memory it is using is not needed any more.
>
> Regards,
>
> Sean
>
> --
> 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
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

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