-
-
Notifications
You must be signed in to change notification settings - Fork 530
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 while moving from one screen to another in the same stack #843
Comments
@abhaynpai this is very scary. plz fix it. |
Just notice you didn't do super.onCreate(null) in MainApplication.java. Not sure if this is the reason. |
Hey @jp928 Even after adding I am unsure on how to fix it. Do you have any idea on the potential root cause for this memory leak? |
I feel like it might be related to this issue perhaps: react-navigation/react-navigation#7078 |
@omaryoussef - I think the it is somewhat related but not exactly. This issue highlights the actual issue with native navigation + screens. If you disable |
It's the same for me! on my situation, I was using too many scenes in the same stack then get a memory leak issue. Anyway, I did try to disable I think it's have a problem who can be to fixing or explain? |
I know how we can recreate the issue but I am unsure on what exactly is causing this memory leak. |
Same issue, not sure if it's a good idea to upgrade to 3.0.0 with this still happening (as the latest release enables screens by default) |
I'm having this bug too. |
The behavior described by the tools as a leak is the consequence of keeping the I hope this resolves the issue, so I will close it since I don't think we can do much more about it. If you have any questions or can propose other solutions, please write here and I can reopen it. |
I've profiled the Navigation router and it doesn’t show any memory leaks. The Navigation router uses Android's native back stack to manage the scenes. Android doesn't call |
@grahammendick using back stack can be a way to go, it is even implemented in the RNScreens, but there were problems with integrating them with React Navigation iirc. Does this approach have benefits other than just not calling this lifecycle method on the |
@WoLewicki A couple of benefits that spring to mind
|
@zoyopo the references on both sides are nulled when the Screen is removed from React view hierarchy, you can see it when going back, the memory is freed then. |
I made two changes -
|
Description
One can observe retained memory while moving across different screens in the application. Even if you have one single stack with 3 different pages, you can observer a memory leak there. I have created a sample project to reproduce this issue. The link is given below
https://github.com/abhaynpai/rn-screens-leak
Screenshots
This is a YouTube video showcasing the leak in the project.
Steps To Reproduce
The steps are given in this GitHub link - https://github.com/abhaynpai/rn-screens-leak
Expected behavior
No memory leak should be displayed while moving across page.
Actual behavior
While moving between pages you can observe multiple memory leaks.
Snack or minimal code example
Package versions
The text was updated successfully, but these errors were encountered: