Actually, the OP's example is final, not static.

Final references cannot be pointed to null, as they cannot be modified.
However, they are also not static, so they should be garbage collected
once the containing object (an activity in this case) itself is garbage
collected.

> Static references remains on memory until the process where your activity
> is
> running is destroyed.
>
> So, in order to avoid memory leaks, point the reference to null in
> onDestroy()
>
> Regards,
>
> Felipe Silveira
>
> On Thu, Sep 24, 2009 at 10:58 AM, Jiri <[email protected]>
> wrote:
>
>>
>> I have a simple question, in my ctivity i define a static private as so:
>>
>> private final FileFetcher ff = new FileFetcher();
>>
>> what happens when this activity is destroyed, is the reference to the
>> FileFetcher completly gone, and can everything be marked for GC?
>>
>> Or would it better to write
>>
>> private FileFetcher ff;
>>
>> and the in my onCreate instantiate the FileFetcher and nullify it in the
>> onDestroy method?


-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html



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