Home Answers Viewqa Java-Beginners What is garbage collection?

 
 


Deepak Kumar
What is garbage collection?
2 Answer(s)      2 years and 7 months ago
Posted in : Java Beginners

Hi,

Tell me about garbage collection. How garbage collection works in java?

Thanks
View Answers

October 5, 2010 at 2:17 PM


<b>Garbage Collection in Java</b>

In Java when program executes the JVM creates the object of the Java classes which is to be executed. In this process these objects are stored into memory. When these objects are not need the JVM process removes these objects and then reclaims the memory. This process of finding the unused Java objects and then freeing objects which is no longer is in use is called the Garbage Collection.
The Garbage collection process is automatic and programmer can?t free the un-used objects. Only JVM automatically runs the Garbage collection process.
The Garbage collector is responsible for running the Garbage collection process in Java.
Check the garbage collection code at http://www.roseindia.net/answers/viewqa/Java-Interview-Questions/1892-garbage-collector.html
Thanks

October 5, 2010 at 2:20 PM


Java programmer can also instruct the Garbage collection for Garbage collection. But Garbage collector will finally decide weather to call Garbage collection process or not.

Following method
System.gc()

may be used to call it explicitly.

Thanks









Related Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.