Files
flipper/docs/leak-canary-plugin.md
Daniel Büchele 159ce69bc8 Docs
Summary: renaming flipper in docs

Reviewed By: passy

Differential Revision: D9871491

fbshipit-source-id: 7a7dcc8421229f3a253efc6a49202dad5c7315d0
2018-09-18 07:01:17 -07:00

1.1 KiB

id, title
id title
leak-canary-plugin LeakCanary

The LeakCanary plugin provides developers with Flipper support for LeakCanary, an open source memory leak detection library.

Setup

Note: this plugin is only available for Android.

Android

First, add the plugin to your Flipper client instance:

import com.facebook.sonar.plugins.leakcanary.LeakCanarySonarPlugin;

client.addPlugin(new LeakCanarySonarPlugin());

Next, build a custom RefWatcher using RecordLeakService: (see LeakCanary docs for more information on RefWatcher)

import com.facebook.sonar.plugins.leakcanary.RecordLeakService;

RefWatcher refWatcher = LeakCanary.refWatcher(this)
    .listenerServiceClass(RecordLeakService.class);
    .buildAndInstall();

Usage

Leaks detected by LeakCanary will appear automatically in Flipper. Each leak will display a hierarchy of objects, beginning from the garbage collector root and ending at the leaked class. Selecting any object in this list will display contents of the object's various fields.