What is garbage collection in Java, and how can it be used ?

Answer Posted / poonam

In computer science, garbage collection (GC) is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program. Garbage collection was invented by John McCarthy around 1959 to solve problems in Lisp.[1][2]
Garbage collection is often portrayed as the opposite of manual memory management, which requires the programmer to specify which objects to deallocate and return to the memory system. However, many systems use a combination of the two approaches, and other techniques such as stack allocation and region inference can carve off parts of the problem. There is an ambiguity of terms, as theory often uses the terms manual garbage collection and automatic garbage collection rather than manual memory management and garbage collection, and does not restrict garbage collection to memory management, rather considering that any logical or physical resource may be garbage collected.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a main method be overloaded?

561


What is the static block?

578


what is static import in java? Explain

545


How do you use substring in java?

531


Give example to differentiate between call by value and call by reference.

581






What is an infinite loop in java? Explain with an example.

574


Can the garbage collection be forced by any means?

526


How do you compare two strings lexicographically?

531


What is a nonetype?

555


What are meta-annotations?

545


How does regex work?

515


Where local and global variables are stored?

533


Is a class subclass of itself?

587


What ide should I use for java?

482


Can we force the garbage collection to run?

525