Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak with mBlurImage #22

Open
techtunde opened this issue Sep 4, 2015 · 1 comment
Open

Memory leak with mBlurImage #22

techtunde opened this issue Sep 4, 2015 · 1 comment

Comments

@techtunde
Copy link

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.

@9c-x
Copy link

9c-x commented Nov 11, 2020

/**
* 使用弱引用
*/
private InvalidationLoop invalidationLoop = new InvalidationLoop(this);

private static class InvalidationLoop implements Choreographer.FrameCallback{
    private WeakReference<BlurLayout> blurLayoutWeakReference;

    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();
        }

    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants