gc java root_Java中什么样的对象才能作为gc root,gc roots有哪些呢?

谢邀。

所有正在运行的线程的栈上的引用变量。所有的全局变量。所有ClassLoader。。。。。。。。。and so on 请看下面。。实在是懒得翻译了。。。

请点击链接 Help - Eclipse Platform 或者查看以下内容

A garbage collection root is an object that is accessible from outside the heap. The following reasons make an object a GC root:

1.System Class

----------Class loaded by bootstrap/system class loader. For example, everything from the rt.jar like java.util.* .

2.JNI Local

----------Local variable in native code, such as user defined JNI code or JVM internal code.

3.JNI Global

----------Global variable in native code, such as user defined JNI code or JVM internal code.

4.Thread Block

----------Object referred to from a currently active thread block.

Thread

----------A started, but not stopped, thread.

5.Busy Monitor

----------Everything that has called wait() or notify() or that is synchronized. For example, by calling synchronized(Object) or by entering a synchronized method. Static method means class, non-static method means object.

6.Java Local

----------Local variable. For example, input parameters or locally created objects of methods that are still in the stack of a thread.

7.Native Stack

----------In or out parameters in native code, such as user defined JNI code or JVM internal code. This is often the case as many methods have native parts and the objects handled as method parameters become GC roots. For example, parameters used for file/network I/O methods or reflection.

7.Finalizable

----------An object which is in a queue awaiting its finalizer to be run.

8.Unfinalized

----------An object which has a finalize method, but has not been finalized and is not yet on the finalizer queue.

9.Unreachable

----------An object which is unreachable from any other root, but has been marked as a root by MAT to retain objects which otherwise would not be included in the analysis.

10.Java Stack Frame

----------A Java stack frame, holding local variables. Only generated when the dump is parsed with the preference set to treat Java stack frames as objects.

11.Unknown

----------An object of unknown root type. Some dumps, such as IBM Portable Heap Dump files, do not have root information. For these dumps the MAT parser marks objects which are have no inbound references or are unreachable from any other root as roots of this type. This ensures that MAT retains all the objects in the dump.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值