-
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
Possible memory leak with useQuery #7013
Comments
I'm having a similar issue with useQuery in React Native. The issue in my case seems to be when I add The initial load is fine but any updates to data in that query using cache.writeQuery will cause an infinite loop of reloading the component over and over again. If I then move to another screen which queries the same data again, it will cause an infinite loop of querying the same data over and over again. In my case, I think it could be to do with the way React Navigation works with screens? When I move from the first screen to the next, the initial screen is still mounted with that first query so when I make the second query on the next page, I wonder if they re-trigger each-other over and over? I didn't have this issue with apollo-client@2.6.10 |
@NathanSaunders01 I think in my case it happens with the default |
Have also observed this leak in a production server-side-rendering deployment. |
Hi everyone! We recently released the Apollo Client 3.9 beta, which should resolve quite a lot of memory leaks like this. Could you please give it a test and report back? For more information, please see the announcement blog post. |
Apollo Client 3.9 has been released finally, and I believe this issue should have been solved with it. If you still see this happening with Apollo Client >=3.9, please open a new issue :) |
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:
Running the same query many times in React-Native shouldn't make the JS heap to grow
Actual outcome:
Running the same query many times causing JS heap to grow meaning there is a memory leak.
How to reproduce the issue:
Run the same query many times, even with fetchPolicy=network-only
This is the diff of snapshots of the heap (before and after running the same query 5 times). As you dan see objects are being retained and not cleaning up.
This is the tree of objects
I think it has to do something with
maybeBroadcastWatch
frominMemoryCache.ts
Does anyone experienced anything like that?
Versions
System:
OS: macOS 10.15.6
Binaries:
Node: 12.18.2 - ~/.nvm/versions/node/v12.18.2/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.5 - ~/.nvm/versions/node/v12.18.2/bin/npm
Browsers:
Chrome: 85.0.4183.102
Safari: 13.1.2
npmPackages:
@apollo/client: ^3.1.5 => 3.1.4
apollo-cache-persist: git@github.com:apollographql/apollo-cache-persist.git#0.2.0 => 0.1.1
The text was updated successfully, but these errors were encountered: