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 in ViewPositionHolder #136
Comments
Do you actually experience memory leaks or it is only a theoretical observation? What you say actually is that GestureView keeps reference to itself, since toPosHolder is a position tracker for GestureView itself. But it is not a definition of a memory leak :) |
I have an actual leak. :) |
Non-removed ViewTreeObserver listeners itself does not introduce memory leak, this can be checked both in Android sources and e.g. in this SO question. If you have a real memory leak then please describe how I can reproduce it and how you understand that it is a leak. |
You are absolutely correct. Non-removed ViewTreeObserver listeners are fine since the view hierarchy is destroyed when the activity is destroyed. My problem is that I have a single activity, but with multiple fragments. FragmentA contains a small view and FragmentB contains my fullscreenview. In FragmentB, I have found this issue while using my app (not yet available, sorry) using LeakCanary (I have |
Hm, can you share logs from LeakCanary here? As I understand the leak can occur only if you'll keep reference to So I can't really see how |
Here is the leak stack from LeakCanary: `* PhotoFullscreenFragment has leaked:
This leak warning occurs after I think the root cause is due to the fact that Hope this help! :) |
By the way, I tried this code, and the leak went away (not sure of the impact though :) ) In the code that starts the animation:
|
Thanks, I think I understand the problem better now, but I'll need to think about a proper fix, since just calling As of your fix, it may work as it is for you, but it will not detect the source view ( |
I had a same proplem @ThierryD |
I am facing a leak too. Not sure if it is the same problem |
@alexvasilkov is there a fix for this leak in sight? It's been reported almost 1.5 year ago? @ThierryD could you elaborate your fix a bit further? |
@alexvasilkov any new on this one? |
Sorry everybody for the long wait, I finally added a fix for this memory leak. |
* commit '8830f41feba436e6c010a5b80d71afea04068daf': (50 commits) Version 2.8.1 Fixed division by zero if recycler view is empty Version 2.8.0 Fixed checkstyle issue Predicting recycler item size when auto scrolling the list Added ViewPager2 transitions support, updated demo Explicitly targeting Java 7 for the library Update libs and tools versions Default animations duration is changed from 300ms to 200ms Simplifying cross activity animation example Fixed sample app ActionBar icons colors Making sure state never has NaNs. Using default pivot point for state animations. Version 2.7.1 Fix for potential memory leak (alexvasilkov#136) Version 2.7.0 Organizing examples into groups Removed deprecated public API. Cleaned up deprecation warnings. Fixed methods badge Added GH actions badge Fixed secrets encryption ... # Conflicts: # build.gradle
It seem there is a memory leak when using
GestureViews
.ViewPositionAnimator
contains afromPosHolder
and atoPosHolder
. ButtoPosHolder.clear()
is never called. As such,view.getViewTreeObserver().removeOnPreDrawListener
is never called, and theOnPreDrawListener
keep a reference to theGestureView
.The text was updated successfully, but these errors were encountered: