-
Notifications
You must be signed in to change notification settings - Fork 347
0x03e LeakMemory_en
Use the following configuration to install
GodEye.instance().install(GodEyeConfig.defaultConfigBuilder().withLeakConfig(new GodEyeConfig.LeakConfig(true, true, new DefaultLeakRefInfoProvider())).build());
or
<leakMemory debug="true" debugNotification="true" leakRefInfoProvider="cn.hikyson.godeye.core.internal.modules.leakdetector.DefaultLeakRefInfoProvider"/>
The leakRefInfoProvider
is used to provide the leaked page information. Will use class DefaultLeakRefInfoProvider
by default. You can customize it and implement the LeakRefInfoProvider
interface. The information provided here will be brought into the subsequent callback leakmemoryinfo,the debug
indicates whether to use it in the debug environment. If it is true, it will analyze all the leaked information. If it is false, it will only show whether the page is leaked, and no more detail information. And the debugNotification
indicates whether to display the leaked notification on the mobile phone when there is a leak.
Use the following methods to observe the output:
try {
GodEye.instance().observeModule(GodEye.ModuleName.LEAK, new Consumer<LeakQueue.LeakMemoryInfo>() {
@Override
public void accept(LeakQueue.LeakMemoryInfo leakMemoryInfo) throws Exception {
}
});
} catch (UninstallException e) {
e.printStackTrace();
}
leakMemoryInfo
will be output after detecting the leak, processing and analyzing the leak, and completing the analysis. The detection process is divided into several steps. Leakmemoryinfo.status saves the current progress of leak detection. The status of the progress is as follows. Only status "done" is the mark of end.
@Retention(RetentionPolicy.SOURCE)
@IntDef({Status.STATUS_INVALID, Status.STATUS_DETECT, Status.STATUS_START, Status.STATUS_PROGRESS, Status.STATUS_RETRY, Status.STATUS_DONE})
public @interface Status {
public static final int STATUS_INVALID = -1;
public static final int STATUS_DETECT = 0;
public static final int STATUS_START = 1;
public static final int STATUS_PROGRESS = 2;
public static final int STATUS_RETRY = 3;
public static final int STATUS_DONE = 4;
}
Because the analysising consumes CPU and memory very much, so you should set the debug and debugNotification to false in the production. In this way, the steps in the production will only have status "done", and the leakMemoryInfo
in the callback will not have the analyzed GC root and other detail informations.