Skip to content
🤔 Documentation issue? Report it

//leakcanary-repo/shark/LeakTrace

LeakTrace

[jvm]\ data class LeakTrace(val gcRootType: LeakTrace.GcRootType, val referencePath: List<LeakTraceReference>, val leakingObject: LeakTraceObject) : Serializable

The best strong reference path from a GC root to the leaking object. "Best" here means the shortest prioritized path. A large number of distinct paths can generally be found leading to a leaking object. Shark prioritizes paths that don’t go through known LibraryLeakReferenceMatcher (because those are known to create leaks so it’s more interesting to find other paths causing leaks), then it prioritize paths that don’t go through java local gc roots (because those are harder to reason about). Taking those priorities into account, finding the shortest path means there are less LeakTraceReference that can be suspected to cause the leak.

Constructors

LeakTrace [jvm]
constructor(gcRootType: LeakTrace.GcRootType, referencePath: List<LeakTraceReference>, leakingObject: LeakTraceObject)

Types

Name Summary
Companion [jvm]
object Companion
GcRootType [jvm]
enum GcRootType : Enum<LeakTrace.GcRootType>

Functions

Name Summary
referencePathElementIsSuspect [jvm]
fun referencePathElementIsSuspect(index: Int): Boolean
Returns true if the referencePath element at the provided index contains a reference that is suspected to cause the leak, ie if index is greater than or equal to the index of the LeakTraceReference of the last non leaking object and strictly lower than the index of the LeakTraceReference of the first leaking object.
toSimplePathString [jvm]
fun toSimplePathString(): String
toString [jvm]
open override fun toString(): String

Properties

Name Summary
gcRootType [jvm]
val gcRootType: LeakTrace.GcRootType
The Garbage Collection root that references the LeakTraceReference.originObject in the first LeakTraceReference of referencePath.
leakingObject [jvm]
val leakingObject: LeakTraceObject
referencePath [jvm]
val referencePath: List<LeakTraceReference>
retainedHeapByteSize [jvm]
val retainedHeapByteSize: Int?
The minimum number of bytes which would be freed if the leak was fixed. Null if the retained heap size was not computed.
retainedObjectCount [jvm]
val retainedObjectCount: Int?
The minimum number of objects which would be unreachable if the leak was fixed. Null if the retained heap size was not computed.
signature [jvm]
val signature: String
A SHA1 hash that represents this leak trace. This can be useful to group together similar leak traces.
suspectReferenceSubpath [jvm]
val suspectReferenceSubpath: Sequence<LeakTraceReference>
A part of referencePath that contains the references suspected to cause the leak. Starts at the last non leaking object and ends before the first leaking object.