Open techtunde opened 9 years ago
/**
使用弱引用 */ private InvalidationLoop invalidationLoop = new InvalidationLoop(this);
private static class InvalidationLoop implements Choreographer.FrameCallback{
private WeakReference
public InvalidationLoop(BlurLayout blurLayout) {
this.blurLayoutWeakReference = new WeakReference<>(blurLayout);
}
@Override
public void doFrame(long frameTimeNanos) {
try {
if (blurLayoutWeakReference != null && blurLayoutWeakReference.get() != null) {
BlurLayout blurLayout = blurLayoutWeakReference.get();
blurLayout.invalidate();
Choreographer.getInstance().postFrameCallbackDelayed(this, 1000 / mFPS);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
When enableBlurBackground() is set to true, if you monitor the memory of the application, you can see that memory goes up each time you do hover.show(), but doesn't go down when you do hover.hide(). If you look at the code for onAnimationEnd() for mGlobalDisappearAnimators, you see that the image within mBlurImage is not freed. I believe this is what causes the memory leak.