1 package shark 2 3 /** 4 * A GcRoot as identified by [HprofRecord.HeapDumpRecord.GcRootRecord] in the heap dump. 5 */ 6 sealed class GcRoot { 7 8 /** 9 * The object id of the object that this gc root references. 10 */ 11 abstract val id: Long 12 13 /** 14 * An unknown gc root. 15 */ 16 class Unknown(override val id: Long) : GcRoot() 17 18 /** 19 * A global variable in native code. 20 */ 21 class JniGlobal( 22 override val id: Long, 23 val jniGlobalRefId: Long 24 ) : GcRoot() 25 26 /** 27 * A local variable in native code. 28 */ 29 class JniLocal( 30 override val id: Long, 31 /** Corresponds to [ThreadObject.threadSerialNumber] */ 32 val threadSerialNumber: Int, 33 /** 34 * frame number in stack trace (-1 for empty) 35 */ 36 val frameNumber: Int 37 ) : GcRoot() 38 39 /** 40 * A java local variable 41 */ 42 class JavaFrame( 43 override val id: Long, 44 /** Corresponds to [ThreadObject.threadSerialNumber] */ 45 val threadSerialNumber: Int, 46 /** 47 * frame number in stack trace (-1 for empty) 48 */ 49 val frameNumber: Int 50 ) : GcRoot() 51 52 /** 53 * Input or output parameters in native code 54 */ 55 class NativeStack( 56 override val id: Long, 57 /** 58 * Corresponds to [ThreadObject.threadSerialNumber] 59 * Note: the corresponding thread is sometimes not found, see: 60 * https://issuetracker.google.com/issues/122713143 61 */ 62 val threadSerialNumber: Int 63 ) : GcRoot() 64 65 /** 66 * A system class 67 */ 68 class StickyClass(override val id: Long) : GcRoot() 69 70 class ThreadBlock( 71 override val id: Long, 72 /** Corresponds to [ThreadObject.threadSerialNumber] */ 73 val threadSerialNumber: Int 74 ) : GcRoot() 75 76 /** 77 * Everything that called the wait() or notify() methods, or 78 * that is synchronized. 79 */ 80 class MonitorUsed(override val id: Long) : GcRoot() 81 82 /** 83 * A thread. 84 * 85 * Added at https://android.googlesource.com/platform/tools/base/+/c0f0d528c155cab32e372dac77370569a386245c 86 */ 87 class ThreadObject( 88 override val id: Long, 89 val threadSerialNumber: Int, 90 val stackTraceSerialNumber: Int 91 ) : GcRoot() 92 93 /** 94 * It's unclear what this is, documentation welcome. 95 */ 96 class ReferenceCleanup(override val id: Long) : GcRoot() 97 98 /** 99 * It's unclear what this is, documentation welcome. 100 */ 101 class VmInternal(override val id: Long) : GcRoot() 102 103 /** 104 * It's unclear what this is, documentation welcome. 105 */ 106 class JniMonitor( 107 override val id: Long, 108 val stackTraceSerialNumber: Int, 109 val stackDepth: Int 110 ) : GcRoot() 111 112 /** 113 * An interned string, see [java.lang.String.intern]. 114 */ 115 class InternedString(override val id: Long) : GcRoot() 116 117 /** 118 * An object that is in a queue, waiting for a finalizer to run. 119 */ 120 class Finalizing(override val id: Long) : GcRoot() 121 122 /** 123 * An object held by a connected debugger 124 */ 125 class Debugger(override val id: Long) : GcRoot() 126 127 /** 128 * An object that is unreachable from any other root, but not a root itself. 129 */ 130 class Unreachable(override val id: Long) : GcRoot() 131 }