-
Notifications
You must be signed in to change notification settings - Fork 585
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 when reloading the app with Results/List Object listeners #2378
Comments
Also, I have tried looking at this from the RN side about any sort of cleanup opportunities before the bundle gets reloaded. Unfortunately, it doesn't look like there is a good option on that side: facebook/react-native#9773 |
Quick bump. Does anyone have any insights on the difference between a Realm Listener and a Results/Object listener and why the latter two would retain after reloading the JavaScript bundle, and/or suggestions on how to work around this? |
I have similar a problem with my project. On Android when we started to use listeners the App would just crash after a couple of reloads. |
From facebook/react-native#9773 it sounds virtually impossible to make a solution which works every time. Removing all listeners in |
@kneth Do you have insights why Results and List object listeners do not leak? |
@dkpalmer Results and List are based by Realm (the underlaying database engine) so they are native (C++) resources. Such resources are probably reclaimed by the operating system - even at reload. But the listener lives in the JS engine, and seems to survive a reload. I have label this issue as a bug as I believe listeners should be reclaimed too. |
This may be resolved with our Hermes support. Will have to verify. |
We have released v11.0.0 which has a complete rewrite of the integration with JSC. I am closing the issue, and ask you to upgrade. If the issue is still observed, please create a new issue. |
Goals
Use Results/List Object listeners during development of a React Native app. This requires restarting the simulator or force-closing the app on device after a certain number of reloads.
Expected Results
Reloading the app during development (DEV mode) should not leak.
Actual Results
Memory leaks when dev-reloading the app with listeners on
RealmResults
and List objects. It does not leak on listeners on theRealm
instance.Steps to Reproduce
addListener
on either aRealmResults
object or a List object.Code Sample
I created a fresh React Native app to demonstrate the issue at https://github.com/dkpalmer/realm-rn-reload-leak/. Inside App.js there are 3 cases within
componentWillMount
:Does not leak when reloading: (1) Realm listener
Does leak when reloading: (2) Results listener and (3) List object listener
Assuming you have the RN CLI and Xcode installed, app can be run by cloning, installing dependencies, and running
react-native run-ios
.Version of Realm and Tooling
The text was updated successfully, but these errors were encountered: