-
public class LeakCanaryThe 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classLeakCanary.ConfigLeakCanary configuration data class. Properties can be updated via copy.
-
Field Summary
Fields Modifier and Type Field Description private static volatile LeakCanary.Configconfigpublic final static LeakCanaryINSTANCE
-
Method Summary
Modifier and Type Method Description final IntentnewLeakDisplayActivityIntent()Returns a new Intent that can be used to programmatically launch the leak display activity. final UnitshowLeakDisplayActivityLauncherIcon(Boolean showLauncherIcon)Dynamically shows / hides the launcher icon for the leak display activity. final UnitdumpHeap()Immediately triggers a heap dump and analysis, if there is at least one retained instance tracked by AppWatcher.objectWatcher. final static LeakCanary.ConfiggetConfig()The current LeakCanary configuration. final static UnitsetConfig(LeakCanary.Config config)-
-
Method Detail
-
newLeakDisplayActivityIntent
final Intent newLeakDisplayActivityIntent()
Returns a new Intent that can be used to programmatically launch the leak display activity.
-
showLeakDisplayActivityLauncherIcon
final Unit showLeakDisplayActivityLauncherIcon(Boolean showLauncherIcon)
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_iconboolean resource:<?xml version="1.0" encoding="utf-8"?> <resources> <bool name="leak_canary_add_launcher_icon">false</bool> </resources>
-
dumpHeap
final Unit 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.
-
getConfig
final static LeakCanary.Config getConfig()
The current LeakCanary configuration. Can be updated at any time, usually by replacing it with a mutated copy, e.g.:
LeakCanary.config = LeakCanary.config.copy(retainedVisibleThreshold = 3)In Java, use LeakCanary.Config.Builder instead:
LeakCanary.Config config = LeakCanary.getConfig().newBuilder() .retainedVisibleThreshold(3) .build(); LeakCanary.setConfig(config);
-
setConfig
final static Unit setConfig(LeakCanary.Config config)
-
-
-
-