PDA

View Full Version : what is garbage collection



saneha
04-24-2011, 05:59 PM
what is the definition and syntax of garbage collection and what is the example of it.

thanks.

Vuhelper
04-24-2011, 06:01 PM
If a program continues to allocate memory for data buffers and eventually exceeds the physical memory capacity, the operating system then has to place parts of the program in virtual memory (on disk) in order to continue, which slows down processing. Writing the code to deallocate memory after a routine no longer needs it is a tedious task that programmers often forget to do. Java performs automatic garbage collection without programmer intervention, which eliminates this coding headache.
Then there a method available in java to run Garbage collection forcefully. System.gc(); method to force the garbage collection on that object.