-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
reading from InMemoryCache causes memory leak (in React Native) #8903
Comments
@DanijelBojcic Hey Daniel! Thanks for opening this issue. I tried running your reproduction, but did not notice any memory leaks against the latest apollo client.
Unfortunately, this might not be possible with JavaScript. Engines will analyze JavaScript as it runs, and the results of this analysis are stored on the heap. In the Chrome V8 panel, this is the Also, one note for people doing memory analysis. Chrome 94 seems to have a bug which crashes when using profiles, so the only way I can get the memory snapshots right now is to run the browser in Incognito mode. @oferitz I would expect the opposite to be true. Later versions should have better memory performance than earlier versions, because we’ve disabled “canonization” in the latest Apollo Client version. I’m not sure if I’ll be able to figure out what’s going on by screenshots alone, but if you run the application with the unminified version of Apollo Client that might be helpful. I’m not denying the existence of memory leaks, and I’m sorry if you’re experiencing them as a result of using Apollo Client! I just need more information to help out. |
@brainkim React really seems to level out at ~15 MB. Here's a React-Native reproduction app: RN-apollo-memory-leak When I profile the apps memory usage in Android Studio it starts around 140 MB. After triggering the read/write cycle once its 185 MB, triggering it again and its 205MB. Calling the garage collector will only release around 10 MB. Versions:
|
@DanijelBojcic Oh yes, I can’t vouch for Apollo Client’s memory safety in React Native. Thanks for the update and reproduction. I’ll take a look when I can, though I’m not too sure about how to debug React Native memory usage yet. |
@oferitz If you’d like, please create a new issue with a description of your memory leak! Just so I can keep these issues tidy and focused. |
@brainkim Thanks for update. Sure. |
We've recently released Apollo Client 3.9 which should solve this problem in most cases. (See this blog post) In React Native, we cannot completely solve it as they lack support for As there is nothing more we can do on our side, I'm going to close this issue. As soon as React Native adds the missing capabilities, the code will automatically pick them up and work even better. |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Intended outcome:
Calling
readFragment
/writeFragment
should not increase memory usage at all.Actual outcome:
Callling
readFreagment
and thenwriteFragment
repeatedly will increase the memory usage.Calling only
readFragment
withoutwriteFragment
will only increase the memory once, which I guess is some caching to avoid unnecessary reads?How to reproduce the issue:
I have created a simple app with reproduction: apollo-memory-leak
Versions
The text was updated successfully, but these errors were encountered: