On Apr 9, 11:07 am, Mark Murphy <mmur...@commonsware.com> wrote: > 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. > First at all singleton could be a member of the application. Then it will garbage collected with application. But what I don't understand why lifespan of Application is not the same as process's lifespan. Process without application doesn't make any sense. As far as I understand one process runs one application. Is it correct?
Andrey -- 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.