GC question.

by Jiri » Thu, 24 Sep 2009 21:59:05 GMT


Sponsored Links
 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?

Jiri

--~--~---------~--~----~------------~-------~--~----~



GC question.

by Felipe Silveira » Thu, 24 Sep 2009 22:17:09 GMT


 Hi Jiri,

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






-- 
Felipe Silveira
Engenharia da Computao
Universidade Federal de Itajub
 http://www.felipesilveira.com.br 
MSN: felipeuni...@hotmail.com
Skype: fsunifei
-------------------------------------------------

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


GC question.

by Mark Murphy » Thu, 24 Sep 2009 22:23:04 GMT


 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.




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



--~--~---------~--~----~------------~-------~--~----~



GC question.

by Jiri » Fri, 25 Sep 2009 14:50:23 GMT


 Thank you both, that was what I needed to know.

J





--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Adwords options for Android Phones...

http://googlemobile.blogspot.com/2008/12/new-adwords-options-for-iphone-and-g1.html

Al.
http://andappstore.com/

-- 
======
Funky Android Limited is registered in England & Wales with the 
company number  6741909. The registered head office is Kemp House, 
152-160 City Road, London,  EC1V 2NX, UK. 

The views expressed in this email are those of the author and not 
necessarily those of Funky Android Limited, it's associates, or it's 
subsidiaries.


--~--~---------~--~----~------------~-------~--~----~

2. port c++ layout engine

Hi,

We are planning to port our own layout engine, written in C++, to
Android.  It will play the role similar to Webkit layout engine.  We
would like to know:

1.  Are there any documents or guidelines to us since the applications
will be written in Java?  Is android.webkit.WebView class a good
example to us?

2.  For the different fonts and drawing, are they handled by the
android.view.View if we follow android.webkit.WebView approach?  Or we
still need to handle them in C++ library code?

Thanks,

Zoneson


--~--~---------~--~----~------------~-------~--~----~
unsubscribe: [EMAIL PROTECTED]
website: 

3. Android on other carriers 3G networks

4. Easy way to identify a missed call? (Broadcast)

5. ::CPU usage

6. Problem about android SDK 1.0 porting on IMX31 board (No pending application record for pid 0)

7. Using File Manager applications to rename files