InterviewSolution
| 1. |
Explain About Garbage Collection In Java? |
|
Answer» JAVA manages MEMORY automatically by removing the unused variable or objects from the memory. This PROCESS is referred to as garbage collection. User java programs cannot free the OBJECT memory , so the garbage collector (gc) in java free’s the objects or variables that are no longer being used by a program. JVM considers an object or variable as alive as long as it is being referenced by a program. Once it finds that the object cannot be reached by the program code, it is removed and so that the unused memory can be reclaimed. Java manages memory automatically by removing the unused variable or objects from the memory. This process is referred to as garbage collection. User java programs cannot free the object memory , so the garbage collector (gc) in java free’s the objects or variables that are no longer being used by a program. JVM considers an object or variable as alive as long as it is being referenced by a program. Once it finds that the object cannot be reached by the program code, it is removed and so that the unused memory can be reclaimed. |
|