Garbage Collection

India
June 20, 2007 8:24am CST
what is Garbage collection in java and when it is used?
1 person likes this
2 responses
@raghwagh (1527)
• India
22 Jun 07
Garbage collection is the process of freeing the memory blocked by unused objects.In c++ when we create a object using new keyword, we had to explecitely delete the onject using a distructor, thus free the memory allocated,blocked, by the unused object.I java deleting the object is not required, it is managed by a thread running in background called Garbace collection, and it performs the operation of deleting the unreferanced objects.This thread is of lowest priority and runs when resources are free.But in cases of real time system there are some problems with this garbage collection as deletion of unused objects takes some time which may hamper the performance.
2 people like this
@renagades (342)
• India
15 Jul 07
Garbage Collection is something like cleaning your house and putting the unwanted in the dustbin . so the Java has GC to collect the object reference , which will not be used further in the program , and put those objects in the garbage collection . this can be done explicitly by the programmer using System.gc() method .