码迷,mamicode.com
首页 > 其他好文 > 详细

GC roots 总结

时间:2014-10-09 00:20:27      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:des   http   io   os   ar   java   for   strong   sp   

 
previous      content      next
 
GC roots

The so-called GC (Garbage Collector) roots are objects special for garbage collector. Garbage collector collects those objects that are not GC roots and are not accessible by references from GC roots.

There are several kinds of GC roots. One object can belong to more than one kind of root. The root kinds are:

  • Class - class loaded by system class loader. Such classes can never be unloaded. They can hold objects via static fields. Please note that classes loaded by custom class loaders are not roots, unless corresponding instances of java.lang.Class happen to be roots of other kind(s).
  • Thread - live thread
  • Stack Local - local variable or parameter of Java method
  • JNI Local - local variable or parameter of JNI method
  • JNI Global - global JNI reference
  • Monitor Used - objects used as a monitor for synchronization
  • Held by JVM - objects held from garbage collection by JVM for its purposes. Actually the list of such objects depends on JVM implementation. Possible known cases are: the system class loader, a few important exception classes which the JVM knows about, a few pre-allocated objects for exception handling, and custom class loaders when they are in the process of loading classes. Unfortunately, JVM provides absolutely no additional detail for such objects. Thus it is up to the analyst to decide to which case a certain "Held by JVM" belongs.

 

If an object is a root, it is specially marked in all views showing individual objects. For example, the following picture shows a fragment of paths view:

bubuko.com,布布扣
 
previous      content      next

 

GC roots 总结

标签:des   http   io   os   ar   java   for   strong   sp   

原文地址:http://www.cnblogs.com/hansongjiang/p/4011424.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!