Question 4:
What are some considerations for selecting a Collection?
What is Garbage Collection and how can you mark an object for Garbage Collection.
Expert Answer
Garbage Collection is the Type of Memory Management.Garbage is nothing but the objects occupying the memory that are no longer used by the program.
The work of Garbage collection is the memory management where the unused objects are located in the memory and those memory must be reclaimed.
Several Languages has the Garbage collector in themselves.Let us consider the Garbage Collector in the JAVA
- Garbage Collectors are Heap in java irrespective of the scope.
- Garbage Collector is the mechanism provided by the Java Virtual Machine.
- Garbage Collecter releives the programmer from memory management.
- We cannot force this Garbage Collector to clear the memory the JVM decides the Garbage collector to clear the memory by JVM heap size