Skip to content

0x03e LeakMemory_en

hui.zhao edited this page Mar 24, 2020 · 5 revisions

LeakMemory

Extra dependencies

AndroidGodEye use LeakCanary to analyze memory leak, you need to add dependency as following

implementation 'cn.hikyson.godeye:godeye-leakcanary:VERSION_NAME'

This library is conflict with Leakcanary, if you have already depends on Leakcanary, you should add this dependency

Install

Use the following configuration to install

GodEye.instance().install(GodEyeConfig.defaultConfigBuilder().withLeakConfig(new GodEyeConfig.LeakConfig(true)).build());

or

<leakCanary debug="true" />

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.

Production and consumption of data

Use the following methods to observe the output:

try {
            GodEye.instance().observeModule(GodEye.ModuleName.LEAK_CANARY, new Consumer<LeakInfo>() {
                @Override
                public void accept(LeakInfo leakInfo) throws Exception {
                }
            });
        } catch (UninstallException e) {
            e.printStackTrace();
        }

leakInfo will be output after analyzd leak info

Because the analysising consumes CPU and memory very much, so you should set the debug to false in the production.

DebugMonitor Dashboard

android_god_eye_leak

Clone this wiki locally