Java Garbage Collection 面试题与答案
问题 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.
问题 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.
问题 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.
问题 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.
问题 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.
用户评价最有帮助的内容:
- What is the purpose of the Young Generation in the Java heap?
- What is the role of the JVM (Java Virtual Machine) in garbage collection?