Java Garbage Collector and Field Variables

2013-10-22T08:46:52

I actually have a quick question which I cannot find an answer to.

I am VERY persistant that my Android/Java application eats up the least amount of RAM as possible as it helps the user experience.

With that being said my question is focused on field variables and the garbage collector.

My application will start up and I have a list of set field variables (hardcoded). Now for the sake of readability I have chosen field variables. If I wish to make a quick change I change the value instead of me looking through my code to see when the variable is actually used.

My field variables in this case are only used ONCE, when the application is loaded for the first time.

Does the garbage collector remove this variable or must I set it null manually. I know a simple int value isn't much to cry over, however I am curious as to the garbage collector.

The object which contains the field will always be in use (it will be an Android ViewPagerAdapter in this case).

Copyright License:
Author:「basickarl」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/19507217/java-garbage-collector-and-field-variables

About “Java Garbage Collector and Field Variables” questions

I actually have a quick question which I cannot find an answer to. I am VERY persistant that my Android/Java application eats up the least amount of RAM as possible as it helps the user experience.
I don't exactly remember but there was an article for Java that explains variable modifiers that makes them prone to be collected by garbage collector. Is there any mechanism for Java to define var...
I am new to Java and confused about the garbage collector in Java. What does it actually do and when does it comes into action. Please describe some of the properties of the garbage collector in Java.
I am new to Java and confused about the garbage collector in Java. What does it actually do and when does it comes into action. Please describe some of the properties of the garbage collector in Java.
I am new to Java and confused about the garbage collector in Java. What does it actually do and when does it comes into action. Please describe some of the properties of the garbage collector in Java.
Finalize methods are invoked by the garbage collector prior to reclaiming the memory occupied by the object, which has the finalize() method. This means you do not know when the objects are going t...
I am trying to understand the garbage collector method. "In Java, your program must call the garbage collector method frequently; otherwise your program will be overrun with garbage objects...
As we know Garbage collector is Thread in java. And every thread will have its logic to execute. So i wanted to know what logic does this Garbage collector use which maintains the memory so well. ...
How does the garbage collector know the objects and variables are out of scope so they can be collected by garbage collector?
In the following JS code, will example1 or example2 be ever cleaned by the garbage collector? Will their memory be ever released by the GC? I am dealing with memory leaks and I have a few such inst...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.