niorgai / StatusBarCompat

Status Bar Utils ---- Change Status Bar Mode Simply
http://niorgai.github.io/2016/03/20/Android-transulcent-status-bar/
MIT License
2.16k stars 349 forks source link

sAnimator leaks window #51

Closed SebRut closed 5 years ago

SebRut commented 5 years ago

LeakCanary reports sAnimator leaking window in startColorAnimation. This could probably be fixed by using a WeakReference to access window or by cancelling the Animator when the corresponding activity is being destroyed.

https://pastebin.com/dAukjhMH

niorgai commented 5 years ago

Consider Window is only been referenced by the animator, after animator finish, window can be release. so it is a temporary leak. I think you can ignore it.

And i will also add WeakReference to window in next version.

niorgai commented 5 years ago

Please check v2.3.2

SebRut commented 5 years ago

I probably will not be able to actually test this before monday, but I think that a reference to window is still bound to the AnimatorUpdateListener. I guess passing the WeakRef to startColorAnimation and doing Window window = windowWeakRef.get();" in onAnimationUpdate could resolve this issue. In relation to this you might be able to remove that AnimatorUpdateListener in onAnimationUpdate if window == null.

SebRut commented 5 years ago

I just checked out 2.3.2 and window is still leaking.

niorgai commented 5 years ago

...Let me check with LeakCanary and fix it later.

niorgai commented 5 years ago

I find that i'm wrong, this is a big memory leak and window will leak forever. Please check 2.3.3, i test it with LeakCanary and it look like fixed.

SebRut commented 5 years ago

Seems to be fixed for me