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. How to Access PreferenceGroup from the code?

Hi,

I have a basic question but unable to figure out an answer inspite of
googling (probably i am searching with a wrong keyword)

I have a preferenceActivity, which loads the following XML:

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android
">
    <PreferenceGroup android:key="@+id/ViewByMode"
         android:title="@string/viewbymode">

        <Preference
             android:key="Range"
            android:title="@string/range" />
       </PreferenceGroup>
</PreferenceScreen>

To the above PreferenceGroup ViewByMode, I would like to add more
Preferences dynamically.  Hence, I need to get a reference to the
PreferenceGroup "ViewByMode".  How do I do it?  How do I get PreferenceGroup
from findViewById(R.id.ViewByMode) or any other similar API?

Thanking in advance,
Vignesh

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

2. OpenGLES sw writes in the wrong framebuffer page

I have a question regarding SurfaceFlinger Layer updates with OpenGLES
sw.

SurfaceFlinger uses OpenGLES (agl) to update layers with alpha or
blending effects (see LayerBase::drawWithOpenGL). During layer
updates, I notice that the 3D sw engine writes data in the wrong
framebuffer page currently sent to the LCD: right writes and wrong
writes are "mixed" as if two processes were updating the screen during
a short while... This behaviour is not compatible with the double
buffering "concept" and it creates inconsistent data visible on the
screen as small horizontal lines (only on hw, not in the emulator).

My questions:
- Is there an available lock mechanism to prevent SurfaceFlinger (ie
OpenGLES sw renderer) to write in the wrong framebuffer page when
updating layers with alpha channel or blending effects (layers without
alpha are properly updated)
- Does anyone encounter such behaviour?


If I disable blending effects in LayerBase.cpp drawWithOpenGL():
+glDisable(GL_BLEND);
    if (UNLIKELY(transformed()
           || !(mFlags & DisplayHardware::DRAW_TEXTURE_EXTENSION) ))

there is no more inconsistent data on the LCD (of course, layers are
not properly displayed because there is no more transparency...)

I put traces in PixelFlinger scanline_t32cb16blend() function and I
verified that there are writes to the wrong framebuffer pages.

Notes:
- I have tried with framebuffer in cacheable & in non cacheable memory
with the same result.
- I have tried with pmem in cacheable & in non cacheable memory with
the same result.

Thanks

--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

3. browser URL string concatenated with "null"

4. how to add new product AOSP?

5. Could not load 'clearsilver-jni': make: *** [out/target/common/docs/offline-sdk-timestamp] Error 45

6. Embedding custom text renderign

7. Problems with saveInstanceState and TextView with LinkMovementMethod in a List View