Welcome to Questionaries, where you can ask questions and receive answers from other members of the community.

Let us know at info@questionaries.org

Explain garbage collection in java?

7 like 0 dislike
Hello
Explain garbage collection in java?
please reply me. i am waiting for your reply.
Thanx
asked 1 year ago by eagles11 (179,830 points)

1 Answer

1 like 0 dislike
 
Best answer
Garbage collection is one of the most important feature of Java. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory. User program cann't directly free the object from memory, instead it is the job of the garbage collector to automatically free the objects that are no longer referenced by a program. Every class inherits finalize() method from java.lang.Object, the finalize() method is called by garbage collector when it determines no more references to the object exists. In Java, it is good idea to explicitly assign null into a variable when no more in use. I Java on calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there is no guarantee when all the objects will garbage collected.
answered 1 year ago by DBA-boss (120,990 points)

Related questions

7 like 0 dislike
1 answer
4 like 0 dislike
0 answers
4 like 0 dislike
0 answers
3 like 0 dislike
1 answer