Garbage collection roots

本文介绍了垃圾回收根节点的概念及分类,包括系统类、JNI本地变量、线程块等,并解释了不可达对象如何被标记及如何在内存分析中处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Garbage collection roots

A garbage collection root is an object that is accessible from outside the heap.

Memory Analyzer categorizes garbage collection roots according to the following list:
System class
A class that was loaded by the bootstrap loader, or the system class loader. For example, this category includes all classes in the  rt.jar file (part of the Java runtime environment), such as those in the  java.util.* package.
JNI local
A local variable in native code, for example user-defined JNI code or JVM internal code.
JNI global
A global variable in native code, for example user-defined JNI code or JVM internal code.
Thread block
An object that was referenced from an active thread block.
Thread
A running thread.
Busy monitor
Everything that called the  wait() or  notify() methods, or that is synchronized, for example by calling the  synchronized(Object) method or by entering a synchronized method. If the method was static, the root is a class, otherwise it is an object.
Java local
A local variable. For example, input parameters, or locally created objects of methods that are still in the stack of a thread.
Native stack
Input or output parameters in native code, for example user-defined JNI code or JVM internal code. Many methods have native parts, and the objects that are handled as method parameters become garbage collection roots. For example, parameters used for file, network, I/O, or reflection operations.
Finalizer
An object that is in a queue, waiting for a finalizer to run.
Unfinalized
An object that has a finalize method, but was not finalized, and is not yet on the finalizer queue.
Unreachable
An object that is unreachable from any other root, but was marked as a root by Memory Analyzer so that the object can be included in an analysis.

Unreachable objects are often the result of optimizations in the garbage collection algorithm. For example, an object might be a candidate for garbage collection, but be so small that the garbage collection process would be too expensive. In this case, the object might not be garbage collected, and might remain as an unreachable object.

By default, unreachable objects are excluded when Memory Analyzer parses the heap dump. These objects are therefore not shown in the histogram, dominator tree, or query results. You can change this behavior by clicking File > Preferences... > IBM Diagnostic Tools for Java - Memory Analyzer, then selecting the Keep unreachable objects check box.

Java stack frame
A Java stack frame, which holds local variables. This type of garbage collection root is only generated if you set the Preferences to treat Java stack frames as objects. For more information, see  Java Basics: Threads and thread stack queries.
Unknown
An object of unknown root type. Some dumps, such as IBM Portable Heap Dump ( .phd) files, do not have root information. In this case, the Memory Analyzer parser marks objects that have no inbound references, or are unreachable from any other root, as unknown. This action ensures that Memory Analyzer retains all the objects in the dump.

转载自:
http://pic.dhe.ibm.com/infocenter/hctool/v1r0/index.jsp?topic=%2Fcom.ibm.java.diagnostics.memory.analyzer.doc%2Fgcroots.html&resultof%3D%2522%2547%2561%2572%2562%2561%2567%2565%2522%2520%2522%2567%2561%2572%2562%2561%2567%2522%2520%2522%2543%256f%256c%256c%2565%2563%2574%2569%256f%256e%2522%2520%2522%2563%256f%256c%256c%2565%2563%2574%2522%2520%2522%2552%256f%256f%2574%2573%2522%2520%2522%2572%256f%256f%2574%2522%2520   



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值