What is garbage collection?

What is garbage collection?

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 Tutorials/Questions & Answers:
what is collections?
WHAT IS GARBAGE COLLECTOR AND HOW IT IS USED
Advertisements
What is garbage collection? - Java Beginners
What is the purpose of garbage collection in Java, and when is it used?
ModuleNotFoundError: No module named 'collectionz'
ModuleNotFoundError: No module named 'collectionz'
ModuleNotFoundError: No module named 'collectionz'
ModuleNotFoundError: No module named 'collectionz'
Garbage Collector
Java garbage collector
Java garbage collection
garbage collection
Garbage collection
Java Garbage collector
Collections
collections
collections
garbage collection in java
GARBAGE COLLECTOR
garbage collector
Java garbage collector
Collections API
collections
collections
collections
Garbage collector thread - Java Beginners
Getting garbage value
Java garbage collection
Java garbage collection
Java garbage collector
c++ garbage collection implementation
Collections in Java
Collections in Java
ModuleNotFoundError: No module named 'garbage'
Java garbage collector
Java garbage collection
garbage collection - Java Beginners
garbage collector - Java Interview Questions
Getting garbage value
Garbage Collector - Java Interview Questions
Garbage Collection
garbage collection implementation dependent java
php garbage collection sessions - PHP
ModuleNotFoundError: No module named 'garbage-translator'
ModuleNotFoundError: No module named 'garbage-translator'
Getting garbage value
collections in java - Java Interview Questions
java collections
collections - Java Interview Questions
garbage collector - Java Interview Questions

Ads