GCRoots 是由哪些對象組成的

參考文檔

GCRoot 是一個可以從堆外訪問的對象

1. System Class (被boostrap 類加載器加載的系統類。如rt.jar)
    Class loaded by bootstrap/system class loader. For example, everything from the rt.jar like java.util.* .
   
2. JNI Local( 一些用戶定義jni code或者jvm的內部代碼局部變量)
    Local variable in native code, such as user defined JNI code or JVM internal code.
    
3. JNI Global( jni 代碼中的全局變量)
    Global variable in native code, such as user defined JNI code or 4. JVM internal code.(jvm內部的代碼)
     
5. Thread Block(被阻塞的線程類 Thread.state)
    Object referred to from a currently active thread block.

6. Thread 正在運行的線程
    A started, but not stopped, thread.
    
7. Busy Monitor(正在等待的線程。Thread.state ==WAITING)
    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.
    
8. Java Local(局部變量,比如一些方法傳入參數或線程棧中方法創建的對象)
    Local variable. For example, input parameters or locally created objects of methods that are still in the stack of a thread.

9.Native Stack(本地方法棧中輸入或輸出參數,如io、文件方法或反射的參數)
    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.
    
10.Finalizable(在回收隊列中的對象)
    An object which is in a queue awaiting its finalizer to be run.
    
11. Unfinalized(覆蓋了finalize方法的對象但是還沒有被放入回收隊列中的對象)
    An object which has a finalize method, but has not been finalized and is not yet on the finalizer queue.

12.Unreachable(從任何其他根無法訪問的對象,但由Memory Analyzer標記爲根,以便該對象可以包含在分析中)
    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.

13. Java Stack Frame(java棧幀的舉報變量,僅當您將“首選項”設置爲將Java堆棧幀視爲對象時,纔會生成此類型的垃圾收集根)
    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.
    
14. 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.

總結來說:

  • 活着的線程,包含處於等待或阻塞的線程
  • java方法區/本地方法區中靜態變量、常量引用的對象
  • 虛擬機棧中的變量的對象引用
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章