>>If you're nulling your static bitmap in onPause why is it static to begin 
>>with?<<

E.g. to have access to bitmaps outside of my activity, in classes that
don't have reference to my activities.

Or, in case there can be multiple instance of an activity, these
instances can share 'expensive' data. But this requires something a
bit more sophisticated than just nulling the static in the 'onDestroy
()'.

In my gallery app i use static caches of thumbnails that are capacity
limited. These caches manage themselves and don't rely on onPause or
onDestroy. I do catch OutOfMemoryExceptions then clean these caches
explicitly and try the operation that threw the execption again. So
far, this has been working for me :)

On Dec 10, 8:27 pm, Matt Kanninen <mathias...@gmail.com> wrote:
> I don't get it.  If you're nulling your static bitmap in onPause why
> is it static to begin with?
>
> Also what you want to do is probably very different for a game that is
> basically all taking place in one activity and trying to avoid garbage
> collecting at all, compared to your standard Android app with an
> activity per screen.
>
> On Dec 10, 4:53 pm, Streets Of Boston <flyingdutc...@gmail.com> wrote:
>
>
>
> > Statically held (caches of) bitmaps may come in very very handy.
> > However, as soon as you do hold static references to 'expensive'
> > resources, be sure to have a proper clean-up strategy. E.g. make sure
> > the capacity of your cache of bitmaps is limited. Be sure to set the
> > static reference to null when the activity is destroyed or paused,
> > etc.
>
> > On Dec 10, 6:05 pm, Matt Kanninen <mathias...@gmail.com> wrote:
>
> > > I recommend the only things you make static be strings, and that for
> > > everything else you are considering making static, instead write it to
> > > file and use static methods, that expect to be passed a context, to
> > > access the data.
>
> > > I think my problems might be camera related, so my plan is to stop
> > > using our own camera related activites and just use an intent to
> > > launch the camera, and then read the returned result.
>
> > > On Dec 10, 1:05 pm, fadden <fad...@android.com> wrote:
>
> > > > On Dec 8, 12:28 pm, skominac <stevan.komi...@gmail.com> wrote:
>
> > > > > So not only is memory of static members not deallocated (which is
> > > > > actually not surprising), but the static references are still alive,
> > > > > pointing to the memory, and can be used to invoke the members back.
> > > > > This last part was surprising to me.
>
> > > > > This is actually not bad, as long as developers are aware of it.
> > > > > Is this Dalvik's feature?
>
> > > > This is the expected behavior.  Keep in mind that the VM doesn't shut
> > > > down between runs of your activity.  You are not necessarily starting
> > > > with a clean slate.- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

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