On Wed, Feb 9, 2011 at 5:55 AM, Kacee <komal...@gmail.com> wrote:
> I have a static instance singleton class object. I want that object to
> be garbage collected/null as soon as I close my application using back
> button.

Your application is not closed using the BACK button. Your activity is
destroyed using the BACK button.

> Whats happening is - My Object is alive, between two launch of
> application and hence retains the state.

Your process is not immediately destroyed when all components (e.g.,
activities) have been destroyed.

> What I want is to make my Class object eligible for gc as soon as I
> have come out of my applciation using "back" button.

Your application is not closed using the BACK button. Your activity is
destroyed using the BACK button.

> I know, android will take care of gc when it will call ondestroy() at
> its own, but I think one should not rely on ondestroy().

Either onDestroy() will be called, or the process will be terminated.

> Can anyone please suggest any way to destroy objects right after
> application is stopped ? (although process is still visible in ddms)

Set static data members to null when you are done with them.

Or, don't put data in static data members that you are concerned about
from a space standpoint.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books

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