Explain Garbage collection mechanism in Java

Questions by Beena   answers by Beena

Showing Answers 1 - 10 of 10 Answers

kuriakose

  • Sep 30th, 2005
 

collecting the objects taht are no longer used. java uses System.gc() method or Runtime.gc() method here

Ravi Savaliya

  • Apr 5th, 2007
 

Like in C++, we can deallocate memory using destuctor, but in Java this mechanism of deallocation memory of object is handled by Garbage Collector, it deallocate memory of the object which no longer needed.

  Was this answer useful?  Yes

nuttyvarun

  • Feb 19th, 2008
 

Garbage collection (GC) is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory used by objects that will never be accessed or mutated again by the application.

  Was this answer useful?  Yes

sampra

  • Feb 20th, 2008
 

Like in c and c++ we have some mechanism to create the object and some mechnaishm to distroy the object .but in java  we have mechanism to create the object but we dont have any  mechanism to distroy the object ..so some data can be unused that unused data is garable but as a doveloper we dont have authority to remove the data tht is done by gc() according to JVM instruction.we cant force to gc ().In following cases object is eligble for garbage collection
1.Hello h=new Hello()
Hello h1=new Hello()
h=h1
then h is eligble for gc
2.Hello h1=new Hello()
Hello h1=null
then create object will be eligble for gc
3 when objecdt is out of scope then object will eligble for gc

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions