//leakcanary-android-core/leakcanary/LeakCanary

LeakCanary

[androidJvm]
object LeakCanary

The entry point API for LeakCanary. LeakCanary builds on top of AppWatcher. AppWatcher notifies LeakCanary of retained instances, which in turns dumps the heap, analyses it and publishes the results.

LeakCanary can be configured by updating config.

Types

NameSummary
Config[androidJvm]
data class Config(dumpHeap: Boolean, dumpHeapWhenDebugging: Boolean, retainedVisibleThreshold: Int, referenceMatchers: List<ReferenceMatcher>, objectInspectors: List<ObjectInspector>, onHeapAnalyzedListener: OnHeapAnalyzedListener, metadataExtractor: MetadataExtractor, computeRetainedHeapSize: Boolean, maxStoredHeapDumps: Int, requestWriteExternalStoragePermission: Boolean, leakingObjectFinder: LeakingObjectFinder, heapDumper: HeapDumper, eventListeners: List<EventListener>, useExperimentalLeakFinders: Boolean)
LeakCanary configuration data class. Properties can be updated via copy.

Functions

NameSummary
dumpHeap[androidJvm]
fun dumpHeap()
Immediately triggers a heap dump and analysis, if there is at least one retained instance tracked by AppWatcher.objectWatcher. If there are no retained instances then the heap will not be dumped and a notification will be shown instead.
newLeakDisplayActivityIntent[androidJvm]
fun newLeakDisplayActivityIntent(): Intent
Returns a new Intent that can be used to programmatically launch the leak display activity.
showLeakDisplayActivityLauncherIcon[androidJvm]
fun showLeakDisplayActivityLauncherIcon(showLauncherIcon: Boolean)
Dynamically shows / hides the launcher icon for the leak display activity. Note: you can change the default value by overriding the leak_canary_add_launcher_icon boolean resource:

Properties

NameSummary
config[androidJvm]
@JvmStatic
@Volatile
var config: LeakCanary.Config
The current LeakCanary configuration. Can be updated at any time, usually by replacing it with a mutated copy, e.g.: