我正在使用其中已使用Leak Canary Library的Android TV应用程序,但是问题是当我使用一段时间后,它向我显示错误“ Dumping Memory。App Freezes。Brrrr”。我在Google上搜索了建议的内容,但仍然出现错误。

在清单中,我已提供写入和读取存储的权限。

申请类别代码:

     public class App extends Application {

private RefWatcher refWatcher;

public static RefWatcher getRefWatcher(Context context) {
    App application = (App) context.getApplicationContext();
    return application.refWatcher;
}

@Override
public void onCreate() {
    super.onCreate();
    refWatcher = LeakCanary.install(this);

}


在我的Activity和Fragments中,我在OnDestroy()中使用了RefWatcher。方法。



        @Override
protected void onDestroy() {

    if (timer != null) {
        timer.cancel();
        timer = null;
    }
    if (handler != null)
        handler.removeCallbacks(Update);
    super.onDestroy();


    RefWatcher refWatcher = App.getRefWatcher(this);
    refWatcher.watch(this);
}


但是我仍然收到“ Dumping Memory”错误。请帮忙。

最佳答案

消息提示,LeakCanary将冻结应用程序以转储其当前内存以进行分析。这是正常行为,是有意的。您应该收到有关可能检测到的泄漏的更多详细信息的通知。您也可以查看“泄漏”应用程序或应用程序的logcat输出以获取详细信息。

09-13 11:29