Package-level declarations¶
Types¶
Name | Summary |
---|---|
ActualMatchingReferenceReaderFactory | [jvm] class ActualMatchingReferenceReaderFactory(referenceMatchers: List<ReferenceMatcher>) : ReferenceReader.Factory<HeapObject> Creates ReferenceReader instances that will follow references from all HeapObjects, applying matching rules provided by referenceMatchers, and not creating any virtual reference. |
AnalyzeCommand | [jvm] class AnalyzeCommand : CliktCommand |
AndroidBuildMirror | [jvm] class AndroidBuildMirror(val manufacturer: String, val sdkInt: Int, val id: String) Caches values from the android.os.Build class in the heap dump. Retrieve a cached instances via fromHeapGraph. |
AndroidMetadataExtractor | [jvm] object AndroidMetadataExtractor : MetadataExtractor |
AndroidNativeSizeMapper | [jvm] class AndroidNativeSizeMapper(graph: HeapGraph) |
AndroidObjectGrowthReferenceMatchers | [jvm] enum AndroidObjectGrowthReferenceMatchers : Enum<AndroidObjectGrowthReferenceMatchers> , ReferenceMatcher.ListBuilder |
AndroidObjectInspectors | [jvm] enum AndroidObjectInspectors : Enum<AndroidObjectInspectors> , ObjectInspector A set of default ObjectInspectors that knows about common AOSP and library classes. |
AndroidObjectSizeCalculator | [jvm] class AndroidObjectSizeCalculator(graph: HeapGraph) : DominatorTree.ObjectSizeCalculator |
AndroidReferenceMatchers | [jvm] enum AndroidReferenceMatchers : Enum<AndroidReferenceMatchers> , ReferenceMatcher.ListBuilder AndroidReferenceMatchers values add ReferenceMatcher instances to a global list via their add method. A ReferenceMatcher is either a IgnoredReferenceMatcher or a LibraryLeakReferenceMatcher. |
AndroidReferenceReaderFactory | [jvm] class AndroidReferenceReaderFactory(referenceMatchers: List<ReferenceMatcher>) : ReferenceReader.Factory<HeapObject> Creates ReferenceReader instances that will follow references from all HeapObjects, applying matching rules provided by referenceMatchers, creating additional virtual instance reference based on known Android classes. |
AndroidReferenceReaders | [jvm] enum AndroidReferenceReaders : Enum<AndroidReferenceReaders> , ChainingInstanceReferenceReader.VirtualInstanceReferenceReader.OptionalFactory |
AndroidResourceIdNames | [jvm] class AndroidResourceIdNames |
AndroidServices | [jvm] object AndroidServices |
ApacheHarmonyInstanceRefReaders | [jvm] enum ApacheHarmonyInstanceRefReaders : Enum<ApacheHarmonyInstanceRefReaders> , ChainingInstanceReferenceReader.VirtualInstanceReferenceReader.OptionalFactory Defines VirtualInstanceReferenceReader factories for common Apache Harmony data structures. |
ApplicationLeak | [jvm] data class ApplicationLeak(val leakTraces: List<LeakTrace>) : Leak A leak found by HeapAnalyzer in your application. |
AppSingletonInspector | [jvm] class AppSingletonInspector(singletonClasses: String) : ObjectInspector Inspector that automatically marks instances of the provided class names as not leaking because they’re app wide singletons. |
ByteArraySourceProvider | [jvm] class ByteArraySourceProvider(byteArray: ByteArray) : DualSourceProvider |
ByteSize | [jvm] @JvmInline value class ByteSize(val inWholeBytes: Long) : Comparable<ByteSize> Inspired by https://github.com/saket/file-size as well as Kotlin’s Duration API. |
ChainingInstanceReferenceReader | [jvm] class ChainingInstanceReferenceReader(virtualRefReaders: List<ChainingInstanceReferenceReader.VirtualInstanceReferenceReader>, flatteningInstanceReader: FlatteningPartitionedInstanceReferenceReader?, fieldRefReader: FieldInstanceReferenceReader) : ReferenceReader<HeapObject.HeapInstance> A ReferenceReader that first delegates expanding to virtualRefReaders in order until one matches (or none), and then always proceeds with fieldRefReader. This means any synthetic ref will be on the shortest path, but we still explore the entire data structure so that we correctly track which objects have been visited and correctly compute dominators and retained size. |
ClassReferenceReader | [jvm] class ClassReferenceReader(graph: HeapGraph, referenceMatchers: List<ReferenceMatcher>) : ReferenceReader<HeapObject.HeapClass> |
CloseableHeapGraph | [jvm] interface CloseableHeapGraph : HeapGraph, Closeable A HeapGraph that should be closed after being used. |
ConstantMemoryMetricsDualSourceProvider | [jvm] class ConstantMemoryMetricsDualSourceProvider(realSourceProvider: DualSourceProvider) : DualSourceProvider Captures IO read metrics without using much memory. |
DecoratedPath | [jvm] class DecoratedPath(delegate: Path) : Path |
DeobfuscateHprofCommand | [jvm] class DeobfuscateHprofCommand : CliktCommand |
Dominators | [jvm] class Dominators(val dominatorNodes: Map<Long, ObjectDominators.DominatorNode>) : Serializable |
DominatorTree | [jvm] class DominatorTree(expectedElements: Int = 4) |
DualSourceProvider | [jvm] interface DualSourceProvider : StreamingSourceProvider, RandomAccessSourceProvider Both a StreamingSourceProvider and a RandomAccessSourceProvider |
DumpProcessCommand | [jvm] class DumpProcessCommand : CliktCommand |
FieldInstanceReferenceReader | [jvm] class FieldInstanceReferenceReader(graph: HeapGraph, referenceMatchers: List<ReferenceMatcher>) : ReferenceReader<HeapObject.HeapInstance> Expands instance fields that hold non null references. |
FileSourceProvider | [jvm] class FileSourceProvider(file: File) : DualSourceProvider |
FilteringLeakingObjectFinder | [jvm] class FilteringLeakingObjectFinder(filters: List<FilteringLeakingObjectFinder.LeakingObjectFilter>) : LeakingObjectFinder Finds the objects that are leaking by scanning all objects in the heap dump and delegating the decision to a list of FilteringLeakingObjectFinder.LeakingObjectFilter |
FindLeakPaths | [jvm] class FindLeakPaths |
FirstHeapTraversal | [jvm] class FirstHeapTraversal(val shortestPathTree: ShortestPathObjectNode, previousTraversal: InitialState) : HeapTraversalOutput |
FlatteningPartitionedInstanceReferenceReader | [jvm] class FlatteningPartitionedInstanceReferenceReader(graph: HeapGraph, instanceReferenceReader: FieldInstanceReferenceReader) FlatteningPartitionedInstanceReferenceReader provides a synthetic and stable representation of a data structure that maps how we think about that data structure instead of how it is internally implemented. You can think of it as surfacing additional direct references to entries that the data structure holds. VirtualInstanceReferenceReader implementations scan references based on known patterns rather than through generic traversals. As a result, they do not surface references and objects that are part of the data structure implementations, such as internal arrays or linked lists. This is a problem because the same traversal is also used to compute retained size, so we need to accounts for all reachable objects. |
GcRoot | [jvm] sealed class GcRoot A GcRoot as identified by HprofRecord.HeapDumpRecord.GcRootRecord in the heap dump. |
GcRootProvider | [jvm] fun interface GcRootProvider |
GcRootReference | [jvm] class GcRootReference(val gcRoot: GcRoot, val isLowPriority: Boolean, val matchedLibraryLeak: LibraryLeakReferenceMatcher?) |
GraphContext | [jvm] class GraphContext In memory store that can be used to store objects in a given HeapGraph instance. This is a simple MutableMap of String to Any, but with unsafe generics access. |
GrowingObjectNodes | [jvm] typealias GrowingObjectNodes = List<ShortestPathObjectNode> |
HeapAnalysis | [jvm] sealed class HeapAnalysis : Serializable The result of an analysis performed by HeapAnalyzer, either a HeapAnalysisSuccess or a HeapAnalysisFailure. This class is serializable however there are no guarantees of forward compatibility. |
HeapAnalysisException | [jvm] class HeapAnalysisException(cause: Throwable) : RuntimeException |
HeapAnalysisFailure | [jvm] data class HeapAnalysisFailure(val heapDumpFile: File, val createdAtTimeMillis: Long, val dumpDurationMillis: Long = DUMP_DURATION_UNKNOWN, val analysisDurationMillis: Long, val exception: HeapAnalysisException) : HeapAnalysis The analysis performed by HeapAnalyzer did not complete successfully. |
HeapAnalysisSuccess | [jvm] data class HeapAnalysisSuccess(val heapDumpFile: File, val createdAtTimeMillis: Long, val dumpDurationMillis: Long = DUMP_DURATION_UNKNOWN, val analysisDurationMillis: Long, val metadata: Map<String, String>, val applicationLeaks: List<ApplicationLeak>, val libraryLeaks: List<LibraryLeak>, val unreachableObjects: List<LeakTraceObject>) : HeapAnalysis The result of a successful heap analysis performed by HeapAnalyzer. |
HeapAnalyzer | [jvm] class HeapAnalyzer(listener: OnAnalysisProgressListener) Analyzes heap dumps to look for leaks. |
HeapDiff | [jvm] class HeapDiff(val traversalCount: Int, val shortestPathTree: ShortestPathObjectNode, val growingObjects: GrowingObjectNodes, previousTraversal: HeapTraversalInput) : HeapTraversalOutput |
HeapDumpRule | [jvm] class HeapDumpRule : ExternalResource |
HeapField | [jvm] class HeapField(val declaringClass: HeapObject.HeapClass, val name: String, val value: HeapValue) Represents a static field or an instance field. |
HeapGraph | [jvm] interface HeapGraph Enables navigation through the heap graph of objects. |
HeapGrowthCommand | [jvm] class HeapGrowthCommand : CliktCommand |
HeapObject | [jvm] sealed class HeapObject An object in the heap dump. |
HeapTraversalInput | [jvm] interface HeapTraversalInput |
HeapTraversalOutput | [jvm] interface HeapTraversalOutput : HeapTraversalInput |
HeapValue | [jvm] class HeapValue(val graph: HeapGraph, val holder: ValueHolder) Represents a value in the heap dump, which can be an object reference or a primitive type. |
HprofDeobfuscator | [jvm] class HprofDeobfuscator Converts a Hprof file to another file with deobfuscated class and field names. |
HprofHeader | [jvm] data class HprofHeader(val heapDumpTimestamp: Long = System.currentTimeMillis(), val version: HprofVersion = HprofVersion.ANDROID, val identifierByteSize: Int = 4) Represents the header metadata of a Hprof file. |
HprofHeapGraph | [jvm] class HprofHeapGraph : CloseableHeapGraph A HeapGraph that reads from an Hprof file indexed by HprofIndex. |
HprofIndex | [jvm] class HprofIndex An index on a Hprof file. See openHeapGraph. |
HprofPrimitiveArrayStripper | [jvm] class HprofPrimitiveArrayStripper Converts a Hprof file to another file with all primitive arrays replaced with arrays of zeroes, which can be useful to remove PII. Char arrays are handled slightly differently because 0 would be the null character so instead these become arrays of ‘?’. |
HprofRecord | [jvm] sealed class HprofRecord A Hprof record. These data structure map 1:1 with how records are written in hprof files. |
HprofRecordReader | [jvm] class HprofRecordReader Reads hprof content from an Okio BufferedSource. |
HprofRecordTag | [jvm] enum HprofRecordTag : Enum<HprofRecordTag> |
HprofVersion | [jvm] enum HprofVersion : Enum<HprofVersion> Supported hprof versions |
HprofWriter | [jvm] class HprofWriter : Closeable Generates Hprof files. |
HprofWriterHelper | [jvm] class HprofWriterHelper(writer: HprofWriter) : Closeable |
IgnoredReferenceMatcher | [jvm] class IgnoredReferenceMatcher(val pattern: ReferencePattern, val patternApplies: (HeapGraph) -> Boolean = ALWAYS) : ReferenceMatcher IgnoredReferenceMatcher should be used to match references that cannot ever create leaks. The shortest path finder will never go through matching references. |
InitialState | [jvm] class InitialState(val scenarioLoopsPerGraph: Int = DEFAULT_SCENARIO_LOOPS_PER_GRAPH) : HeapTraversalInput |
InteractiveCommand | [jvm] class InteractiveCommand : CliktCommand |
JavaLocalReferenceReader | [jvm] class JavaLocalReferenceReader(val graph: HeapGraph, referenceMatchers: List<ReferenceMatcher>) : ChainingInstanceReferenceReader.VirtualInstanceReferenceReader |
JdkReferenceMatchers | [jvm] enum JdkReferenceMatchers : Enum<JdkReferenceMatchers> , ReferenceMatcher.ListBuilder |
JvmObjectGrowthReferenceMatchers | [jvm] enum JvmObjectGrowthReferenceMatchers : Enum<JvmObjectGrowthReferenceMatchers> , ReferenceMatcher.ListBuilder |
JvmTestHeapDumper | [jvm] object JvmTestHeapDumper |
KeyedWeakReferenceFinder | [jvm] object KeyedWeakReferenceFinder : LeakingObjectFinder Finds all objects tracked by a KeyedWeakReference, ie all objects that were passed to ObjectWatcher.watch. |
Leak | [jvm] sealed class Leak : Serializable A leak found by HeapAnalyzer, either an ApplicationLeak or a LibraryLeak. |
LeakingObjectFinder | [jvm] fun interface LeakingObjectFinder Finds the objects that are leaking, for which Shark will compute leak traces. |
LeaksAndUnreachableObjects | [jvm] data class LeaksAndUnreachableObjects(val applicationLeaks: List<ApplicationLeak>, val libraryLeaks: List<LibraryLeak>, val unreachableObjects: List<LeakTraceObject>) |
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. |
LeakTraceObject | [jvm] data class LeakTraceObject(val type: LeakTraceObject.ObjectType, val className: String, val labels: Set<String>, val leakingStatus: LeakTraceObject.LeakingStatus, val leakingStatusReason: String, val retainedHeapByteSize: Int?, val retainedObjectCount: Int?) : Serializable |
LeakTracer | [jvm] fun interface LeakTracer |
LeakTraceReference | [jvm] data class LeakTraceReference(val originObject: LeakTraceObject, val referenceType: LeakTraceReference.ReferenceType, val owningClassName: String, val referenceName: String) : Serializable A LeakTraceReference represents an origin LeakTraceObject and either a reference from that object to the LeakTraceObject in the next LeakTraceReference in LeakTrace.referencePath, or to LeakTrace.leakingObject if this is the last LeakTraceReference in LeakTrace.referencePath. |
LibraryLeak | [jvm] data class LibraryLeak(val leakTraces: List<LeakTrace>, val pattern: ReferencePattern, val description: String) : Leak A leak found by HeapAnalyzer, where the only path to the leaking object required going through a reference matched by pattern, as provided to a LibraryLeakReferenceMatcher instance. This is a known leak in library code that is beyond your control. |
LibraryLeakReferenceMatcher | [jvm] data class LibraryLeakReferenceMatcher(val pattern: ReferencePattern, val description: String = "", val patternApplies: (HeapGraph) -> Boolean = ALWAYS) : ReferenceMatcher LibraryLeakReferenceMatcher should be used to match references in library code that are known to create leaks and are beyond your control. The shortest path finder will only go through matching references after it has exhausted references that don’t match, prioritizing finding an application leak over a known library leak. Library leaks will be reported as LibraryLeak instead of ApplicationLeak. |
MatchingGcRootProvider | [jvm] class MatchingGcRootProvider(referenceMatchers: List<ReferenceMatcher>) : GcRootProvider TODO Extracted from PathFinder, this should eventually be part of public API surface and we should likely also revisit the gc root type filtering which happens during heap parsing, as that’s not really a concern for the heap parser and more for path finding. There are probably memory concerns as well there though. We could: |
MetadataExtractor | [jvm] fun interface MetadataExtractor Extracts metadata from a hprof to be reported in HeapAnalysisSuccess.metadata. |
Neo4JCommand | [jvm] class Neo4JCommand : CliktCommand Example commands: |
ObjectArrayReferenceReader | [jvm] class ObjectArrayReferenceReader : ReferenceReader<HeapObject.HeapObjectArray> |
ObjectDominators | [jvm] class ObjectDominators Exposes high level APIs to compute and render a dominator tree. This class needs to be public to be used by other LeakCanary modules but is internal and its API might change at any moment. |
ObjectGrowthDetector | [jvm] class ObjectGrowthDetector(gcRootProvider: GcRootProvider, referenceReaderFactory: ReferenceReader.Factory<HeapObject>) Looks for objects that have grown in outgoing references in a new heap dump compared to a previous heap dump by diffing heap traversals. |
ObjectInspector | [jvm] fun interface ObjectInspector Provides LeakCanary with insights about objects (classes, instances and arrays) found in the heap. inspect will be called for each object that LeakCanary wants to know more about. The implementation can then use the provided ObjectReporter to provide insights for that object. |
ObjectInspectors | [jvm] enum ObjectInspectors : Enum<ObjectInspectors> , ObjectInspector A set of default ObjectInspectors that knows about common JDK objects. |
ObjectReporter | [jvm] class ObjectReporter(val heapObject: HeapObject) Enables ObjectInspector implementations to provide insights on heapObject, which is an object (class, instance or array) found in the heap. |
OnAnalysisProgressListener | [jvm] fun interface OnAnalysisProgressListener Reports progress from the HeapAnalyzer as they occur, as Step values. |
OnHprofRecordListener | [jvm] fun interface OnHprofRecordListener Listener passed in to StreamingRecordReaderAdapter.readRecords, gets notified for each HprofRecord found in the heap dump which types is in the set of the recordTypes parameter passed to StreamingRecordReaderAdapter.readRecords. |
OnHprofRecordTagListener | [jvm] fun interface OnHprofRecordTagListener Listener passed in to StreamingHprofReader.readRecords, gets notified for each HprofRecordTag found in the heap dump. |
OpenJdkInstanceRefReaders | [jvm] enum OpenJdkInstanceRefReaders : Enum<OpenJdkInstanceRefReaders> , ChainingInstanceReferenceReader.VirtualInstanceReferenceReader.OptionalFactory Defines VirtualInstanceReferenceReader factories for common OpenJDK data structures. |
OpenJdkReferenceReaderFactory | [jvm] class OpenJdkReferenceReaderFactory(referenceMatchers: List<ReferenceMatcher>) : ReferenceReader.Factory<HeapObject> |
PathFindingResults | [jvm] class PathFindingResults(val pathsToLeakingObjects: List<ReferencePathNode>, val dominatorTree: DominatorTree?) |
PrimitiveType | [jvm] enum PrimitiveType : Enum<PrimitiveType> A primitive type in the prof. |
PrioritizingShortestPathFinder | [jvm] class PrioritizingShortestPathFinder : ShortestPathFinder Not thread safe. |
ProguardMapping | [jvm] class ProguardMapping |
ProguardMappingHelper | [jvm] class ProguardMappingHelper(proguardMapping: ProguardMapping) |
ProguardMappingReader | [jvm] class ProguardMappingReader(proguardMappingInputStream: InputStream) |
RandomAccessHprofReader | [jvm] class RandomAccessHprofReader : Closeable Reads records in a Hprof source, one at a time with a specific position and size. Call openReaderFor to obtain a new instance. |
RandomAccessSource | [jvm] interface RandomAccessSource : Closeable |
RandomAccessSourceProvider | [jvm] fun interface RandomAccessSourceProvider Can open RandomAccessSource instances. |
RealLeakTracerFactory | [jvm] class RealLeakTracerFactory(shortestPathFinderFactory: ShortestPathFinder.Factory, objectInspectors: List<ObjectInspector>, listener: RealLeakTracerFactory.Event.Listener) : LeakTracer.Factory |
Reference | [jvm] data class Reference(val valueObjectId: Long, val isLowPriority: Boolean, val isLeafObject: Boolean = false, val lazyDetailsResolver: Reference.LazyDetails.Resolver) TODO Review as public API. |
ReferenceLocationType | [jvm] enum ReferenceLocationType : Enum<ReferenceLocationType> TODO This is quite similar to the leaktrace equivalent |
ReferenceMatcher | [jvm] sealed class ReferenceMatcher Used to pattern match known patterns of references in the heap, either to ignore them (IgnoredReferenceMatcher) or to mark them as library leaks (LibraryLeakReferenceMatcher), which lowers their traversal priority when exploring the heap. |
ReferencePattern | [jvm] sealed class ReferencePattern : Serializable A pattern that will match references for a given ReferenceMatcher. |
ReferenceReader | [jvm] fun interface ReferenceReader<T : HeapObject> |
RepeatingScenarioObjectGrowthDetector | [jvm] interface RepeatingScenarioObjectGrowthDetector |
Retained | [jvm] @JvmInline value class Retained |
SharkCliCommand | [jvm] class SharkCliCommand : CliktCommand |
SharkLog | [jvm] object SharkLog Central Logger for all Shark artifacts. Set logger to change where these logs go. |
ShortestPathFinder | [jvm] fun interface ShortestPathFinder |
ShortestPathObjectNode | [jvm] class ShortestPathObjectNode(val name: String, val parent: ShortestPathObjectNode?) |
StreamingHprofReader | [jvm] class StreamingHprofReader Reads the entire content of a Hprof source in one fell swoop. Call readerFor to obtain a new instance. |
StreamingRecordReaderAdapter | [jvm] class StreamingRecordReaderAdapter(streamingHprofReader: StreamingHprofReader) Wraps a StreamingHprofReader to provide a higher level API that streams HprofRecord instances. |
StreamingSourceProvider | [jvm] fun interface StreamingSourceProvider Can open Source instances. |
StripHprofCommand | [jvm] class StripHprofCommand : CliktCommand |
ThrowingCancelableFileSourceProvider | [jvm] class ThrowingCancelableFileSourceProvider(file: File, throwIfCanceled: Runnable) : DualSourceProvider A DualSourceProvider that invokes throwIfCanceled before every read, allowing cancellation of IO based work built on top by throwing an exception. |
ValueHolder | [jvm] sealed class ValueHolder A value in the heap dump, which can be a ReferenceHolder or a primitive type. |
VirtualizingMatchingReferenceReaderFactory | [jvm] class VirtualizingMatchingReferenceReaderFactory(referenceMatchers: List<ReferenceMatcher>, virtualRefReadersFactory: ChainingInstanceReferenceReader.VirtualInstanceReferenceReader.ChainFactory) : ReferenceReader.Factory<HeapObject> Creates ReferenceReader instances that will follow references from all HeapObjects, applying matching rules provided by referenceMatchers, creating additional virtual instance reference based on the list of VirtualInstanceReferenceReader created by virtualRefReadersFactory. |
Functions¶
Properties¶
Name | Summary |
---|---|
bytes | [jvm] val Int.bytes: ByteSize val Long.bytes: ByteSize |
BYTES_PER_GB | [jvm] const val BYTES_PER_GB: Long |
BYTES_PER_KB | [jvm] const val BYTES_PER_KB: Long |
BYTES_PER_MB | [jvm] const val BYTES_PER_MB: Long |
gigabytes | [jvm] val Int.gigabytes: ByteSize val Long.gigabytes: ByteSize |
hexIdentityHashCode | [jvm] val HeapObject.HeapInstance.hexIdentityHashCode: String? The system identity hashCode represented as hex, or null if it couldn’t be found. This is the string identifier you see when calling Object.toString() at runtime on a class that does not override its hashCode() method, e.g. com.example.MyThing@6bd57cf |
identityHashCode | [jvm] val HeapObject.HeapInstance.identityHashCode: Int? The system identity hash code, or null if it couldn’t be found. |
kilobytes | [jvm] val Int.kilobytes: ByteSize val Long.kilobytes: ByteSize |
megabytes | [jvm] val Int.megabytes: ByteSize val Long.megabytes: ByteSize |
UNKNOWN_RETAINED | [jvm] val UNKNOWN_RETAINED: Retained |
ZERO_BYTES | [jvm] val ZERO_BYTES: ByteSize |
ZERO_RETAINED | [jvm] val ZERO_RETAINED: Retained |