Java Garbage Collection Interview Questions and Answers
Ques 21. Explain the concept of 'Garbage Collection Roots' in Java.
Garbage Collection Roots are objects that are considered to be reachable at all times and serve as starting points for the garbage collector. Examples include local variables, active threads, and static variables.
Ques 22. What is the 'Reference' class in Java, and how is it used in garbage collection?
The 'Reference' class is part of the java.lang.ref package and provides a way to create and manipulate references to objects. It is often used in advanced memory management scenarios and garbage collection.
Ques 23. How can you monitor and analyze garbage collection performance in Java?
Garbage collection performance can be monitored using tools like VisualVM, JConsole, and other profiling tools. Analyzing garbage collection logs and metrics helps identify issues and optimize performance.
Ques 24. Explain the concept of 'GC overhead limit exceeded' error in Java.
The 'GC overhead limit exceeded' error occurs when the JVM spends too much time on garbage collection, exceeding a specified threshold (98% by default) of the total time. It indicates a potential performance issue.
Ques 25. What is the 'CMSInitialMarkPause' phase in the CMS garbage collector?
The 'CMSInitialMarkPause' is the initial phase of the CMS (Concurrent Mark-Sweep) garbage collector. During this phase, the collector identifies and marks live objects in the Old Generation while briefly pausing application threads.
Most helpful rated by users: