我如何解决此内存泄漏,我正在使用此代码与处理程序一起使用。
public static Handler handlerKillInfoBar = new MyHandler();
if (handlerKillInfoBar != null) {
handlerKillInfoBar.removeCallbacksAndMessages(null);
}
handlerKillInfoBar.postDelayed(() -> {
// doing some work here. when user navigate between activites then memory leaks happend and show attached information.
}, 5000);
看起来BaseActivity
类具有一个timerHearBeatApiCall
静态字段,它是LambdaObserver,VodActivity
对其进行预订。 VodActivity
应在收到其onDestroy()
回调时退订。
此外,您应该升级到LeakCanary 2.x