-
public final class HeapAnalysisConfig
-
-
Field Summary
Fields Modifier and Type Field Description private final List<ReferenceMatcher>referenceMatchersprivate final List<ObjectInspector>objectInspectorsprivate final MetadataExtractormetadataExtractorprivate final BooleancomputeRetainedHeapSizeprivate final LeakingObjectFinderleakingObjectFinderprivate final BooleanstripHeapDump
-
Constructor Summary
Constructors Constructor Description HeapAnalysisConfig(List<ReferenceMatcher> referenceMatchers, List<ObjectInspector> objectInspectors, MetadataExtractor metadataExtractor, Boolean computeRetainedHeapSize, LeakingObjectFinder leakingObjectFinder, Boolean stripHeapDump)
-
Method Summary
Modifier and Type Method Description final List<ReferenceMatcher>getReferenceMatchers()Known patterns of references in the heap, added here either to ignore them (IgnoredReferenceMatcher) or to mark them as library leaks (LibraryLeakReferenceMatcher). final List<ObjectInspector>getObjectInspectors()List of ObjectInspector that provide LeakCanary with insights about objects found in the heap. final MetadataExtractorgetMetadataExtractor()Extracts metadata from a hprof to be reported in shark.HeapAnalysisSuccess.metadata. final BooleangetComputeRetainedHeapSize()Whether to compute the retained heap size, which is the total number of bytes in memory that would be reclaimed if the detected leaks didn't happen. final LeakingObjectFindergetLeakingObjectFinder()Finds the objects that are leaking, for which LeakCanary will compute leak traces. final BooleangetStripHeapDump()Whether the first step after a heap dump should be to replace the content of all arrays with zeroes. -
-
Method Detail
-
getReferenceMatchers
final List<ReferenceMatcher> getReferenceMatchers()
Known patterns of references in the heap, added here either to ignore them (IgnoredReferenceMatcher) or to mark them as library leaks (LibraryLeakReferenceMatcher).
When adding your own custom LibraryLeakReferenceMatcher instances, you'll most likely want to set LibraryLeakReferenceMatcher.patternApplies with a filter that checks for the Android OS version and manufacturer. The build information can be obtained by calling shark.AndroidBuildMirror.fromHeapGraph.
Defaults to AndroidReferenceMatchers.appDefaults
-
getObjectInspectors
final List<ObjectInspector> getObjectInspectors()
List of ObjectInspector that provide LeakCanary with insights about objects found in the heap. You can create your own ObjectInspector implementations, and also add a shark.AppSingletonInspector instance created with the list of internal singletons.
Defaults to AndroidObjectInspectors.appDefaults
-
getMetadataExtractor
final MetadataExtractor getMetadataExtractor()
Extracts metadata from a hprof to be reported in shark.HeapAnalysisSuccess.metadata. Called on a background thread during heap analysis.
Defaults to AndroidMetadataExtractor
-
getComputeRetainedHeapSize
final Boolean getComputeRetainedHeapSize()
Whether to compute the retained heap size, which is the total number of bytes in memory that would be reclaimed if the detected leaks didn't happen. This includes native memory associated to Java objects (e.g. Android bitmaps).
Computing the retained heap size can slow down the analysis because it requires navigating from GC roots through the entire object graph, whereas shark.HeapAnalyzer would otherwise stop as soon as all leaking instances are found.
Defaults to true.
-
getLeakingObjectFinder
final LeakingObjectFinder getLeakingObjectFinder()
Finds the objects that are leaking, for which LeakCanary will compute leak traces.
Defaults to a FilteringLeakingObjectFinder that scans all objects in the heap dump and delegates the decision to AndroidObjectInspectors.appLeakingObjectFilters.
-
getStripHeapDump
final Boolean getStripHeapDump()
Whether the first step after a heap dump should be to replace the content of all arrays with zeroes. This increases the overall processing time but limits the amount of time the heap dump exists on disk with potential PII.
-
-
-
-