That's right, I'd heard of people getting leaks on apps that kept doing
configuration changes.

Kris
On Jan 14, 2013 6:21 PM, "Streets Of Boston" <[email protected]>
wrote:

> An Activity's onDestroy is called all the time (but not every time :)).
>
> It is true that you can't *rely *on it being called, though.
>
> E.g. the onDestroy is always called when you click the 'back' key or do
> some other action (code-execution) that causes the Acitivity's 'finish()'
> method to be called.
>
> On Monday, January 14, 2013 11:55:10 AM UTC-5, Kristopher Micinski wrote:
>>
>> While you say that Activities only die when the process is about to be
>> destroyed (or usually die), I have heard that this is not the case.
>> This is mostly hearsay from developers and people I work with saying
>> that memory leaks because of this were really a problem, but I'd have
>> to look into it with some examples (of layouts that really use memory,
>> I'm thinking galleries and nested views, etc..) before making any
>> definite calls.
>>
>> Kris
>>
>> On Mon, Jan 14, 2013 at 9:37 AM, G. Blake Meike <[email protected]>
>> wrote:
>> > After spending considerable time looking at this issue, I strongly
>> suggest
>> > that you look into an Intent Service, for any long running task.  Using
>> > AsyncTasks is just fraught.
>> >
>> > First of all, onDestroy is only called best effort.  If you care about
>> > getting it done, you can't do it in onDestroy.  Further, as kris points
>> out,
>> > onDestroy is, often, called just as your *process* is about to be
>> destroyed.
>> > Worrying about allocation of memory in your process, just as it is
>> > destroyed, is pretty pointless.
>> >
>> > There are two issues you need to consider: making your program correct
>> > according to Java ("If mutable state is referenced from more than one
>> > thread, all references must take place holding a single lock" - B.
>> Goetz,
>> > paraphrased).  You also have to be sure that the lifecycles of
>> unmanaged
>> > objects (e.g. AsyncTasks) don't interfere with the lifecycles of
>> managed
>> > objects (Activities).
>> >
>> > Nulling out pointers and AsyncTasks that survive screen reorientation
>> > (despite the fact that I proposed it myself, at one point) are just
>> Voodoo.
>> >
>> > G. Blake Meike
>> > Marakana
>> >
>> > Programming Android 2ed is now in stores:
>> > http://bit.ly/**programmingandroid <http://bit.ly/programmingandroid>
>> >
>> >
>> > On Monday, January 14, 2013 1:10:52 AM UTC-8, Greenhand wrote:
>> >>
>> >> Thank you.
>> >> Another related question, in section "5. Implement a more intelligent
>> >> AsyncTask dealing with screen orientation" of
>> >> http://blog.**doityourselfandroid.com/2010/**11/14/handling-progress-*
>> *dialogs-and-screen-**orientation-changes/<http://blog.doityourselfandroid.com/2010/11/14/handling-progress-dialogs-and-screen-orientation-changes/>,
>>
>> >> it has private AsyncTaskComplex activity in ListFresher as a member
>> >> variable. Shouldn't it be null out because it is not a static Activity
>> >> references?
>> >>
>> >>
>> >> Kristopher Micinski於 2013年1月14日星期一UTC+**8下午4時24分53秒寫道:
>> >>>
>> >>> Basically, as long as you aren't hanging static Activity references
>> >>> you should be fine.  The main activity will be thrown away upon its
>> >>> destruction, at which point the Activity will be thrown away: along
>> >>> with its contents.  Of course, if you're holding onto Views elsewhere
>> >>> that's bad (i.e., don't hold static refs).
>> >>>
>> >>> kris
>> >>>
>> >>> On Mon, Jan 14, 2013 at 1:42 AM, Greenhand <[email protected]>
>> wrote:
>> >>> > I read
>> >>> >
>> >>> > http://android-developers.**blogspot.tw/2009/01/avoiding-**
>> memory-leaks.html<http://android-developers.blogspot.tw/2009/01/avoiding-memory-leaks.html>
>> >>> > about avoiding memory leaks.
>> >>> > I would like to know whether I should null out all member
>> variables,
>> >>> > such as
>> >>> > TextView and Button in onDestroy()? Or, unregistering listener,
>> >>> > unbinding
>> >>> > service and etc.in onDestroy() are enough to prevent memory leak?
>> >>> >
>> >>> > --
>> >>>
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Android Developers" group.
>> > To post to this group, send email to android-d...@**googlegroups.com
>> > To unsubscribe from this group, send email to
>> > android-developers+**[email protected]
>> > For more options, visit this group at
>> > http://groups.google.com/**group/android-developers?hl=en<http://groups.google.com/group/android-developers?hl=en>
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to