ailinykh wrote:
> 
> On Apr 9, 8:11 am, Mark Murphy <mmur...@commonsware.com> wrote:
>> Donal Rafferty wrote:
>>> The singleton wont be killed by the system automatically like a service
>>> which could lead to GC problems
>> Correct. Objects held in static data members, or referenced from a
>> static data member, will not be garbage collected. Hence, you need to
>> remember to null out those static data member references. Services, on
>> the other hand, will garbage collect automatically, assuming you do not
>> put one in a static data member yourself.
>>
> Why it should be garbage collected? It lives and dies with
> Application.

Static data members live and die with the process by default, which is
not the same as the lifespan of an Application object.

If you want a static data member to live and die with the Application,
then you need to null out the data member when the Application object is
terminated.

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

Warescription: Three Android Books, Plus Updates, One Low Price!

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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to