AppWidgets: Reusing RemoteViews instance leaks memory?
2 posts by 2 authors in
Android Developers
|
|
Join group to reply
|
I'm writing a widget. Currently, I'm have a simple ImageView, and
calling RemoteViews. setImageViewBitmap(). I'm using a service to do
the updates.
I thought it might be a good idea to reuse an existing RemoteViews
instance, so I'm only querying it the first time around, and
subsequently simply call setImageViewBitmap() with the new image.
This works well initially, but after some time I first start getting
"!!! FAILED BINDER TRANSACTION !!!" errors, and later, an OutOfMemory
exception.
Simply creating a new RemoveViews instance every time works flawlessy
on the other hand. I'm just curios why that would be, any ideas?
calling RemoteViews.
the updates.
I thought it might be a good idea to reuse an existing RemoteViews
instance, so I'm only querying it the first time around, and
subsequently simply call setImageViewBitmap() with the new image.
This works well initially, but after some time I first start getting
"!!! FAILED BINDER TRANSACTION !!!" errors, and later, an OutOfMemory
exception.
Simply creating a new RemoveViews instance every time works flawlessy
on the other hand. I'm just curios why that would be, any ideas?
|
Join group to reply
|
Re: [android-developers] AppWidgets: Reusing RemoteViews instance leaks memory?
So internally RemoteViews is simply a set of actions that are
"serialized" and sent to another process. Each time you make a call
to something like setDouble(), you're adding an additional action to
RemoteViews' internal list.
Because there isn't a way of clearing these actions from a RemoteViews
object, all of your successive setImageViewBitmap() calls, along with
their Bitmaps, remain in the internal list, and are actually
"serialized" and applied each time your send it. :(
In this case it's best to just create a new RemoteViews object every time.
j
--
Jeff Sharkey
jsharkey@android.com
"serialized" and sent to another process. Each time you make a call
to something like setDouble(), you're adding an additional action to
RemoteViews' internal list.
Because there isn't a way of clearing these actions from a RemoteViews
object, all of your successive setImageViewBitmap() calls, along with
their Bitmaps, remain in the internal list, and are actually
"serialized" and applied each time your send it. :(
In this case it's best to just create a new RemoteViews object every time.
j
- show quoted text -
Jeff Sharkey
jsharkey@android.com