Package 

Object LeakCanary


  • 
    public class 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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public final class LeakCanary.Config

      LeakCanary configuration data class. Properties can be updated via copy.

    • Method Detail

      • 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_icon boolean 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);