Skip to content
🤔 Documentation issue? Report it

//leakcanary/shark/LeakTrace

LeakTrace

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 fun LeakTrace(gcRootType: LeakTrace.GcRootType, referencePath: List<LeakTraceReference>, leakingObject: LeakTraceObject)

Types

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

Functions

Name Summary
referencePathElementIsSuspect 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 fun toSimplePathString(): String
toString open override fun toString(): String

Properties

Name Summary
gcRootType val gcRootType: LeakTrace.GcRootType
The Garbage Collection root that references the LeakTraceReference.originObject in the first LeakTraceReference of referencePath.
leakingObject val leakingObject: LeakTraceObject
referencePath val referencePath: List<LeakTraceReference>
retainedHeapByteSize 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 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 val signature: String
A SHA1 hash that represents this leak trace. This can be useful to group together similar leak traces.
suspectReferenceSubpath 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.