Memory Leak caused by MutationStore?
See original GitHub issueIntended outcome: My app requires a lot of mutations, making small updates to the DB continuously. Just a simple mutation:
await client.mutate({
mutation: gql`
mutation {
${gqlStatements.join('')}
}
`
});
Actual outcome:
Everything functions fine, but the memory heap fills up with mutationString
’s that never seem to be collected.
How to reproduce the issue: Simply run a much of simple mutations and check the heap. Here’s a screenshop of Chrome Dev Tools: https://imgur.com/a/zPTKM
Version
- apollo-client@1.9.3
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
How does a state update on an unmounted component cause ...
How does this cause a memory leak? It's not guaranteed to, but it might depending on what's causing you to set state after...
Read more >Solving Memory Leaks with React Native - Enquero
Memory leaks are a problem every developer has to face eventually. ... Leaks are the cause of the whole class of problems: slowdowns,...
Read more >Memory leak - Wikipedia
In computer science, a memory leak is a type of resource leak that occurs when a computer ... system memory as an application...
Read more >How to fix the React memory leak warning - DEV Community
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your...
Read more >Memory leak - OWASP Foundation
Memory leaks have two common and sometimes overlapping causes: Error conditions and other exceptional circumstances. Confusion over which part of the program is ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sure! Although I’m not really familiar with the react toolset, so I just mocked up a really simple vanilla JS example here: https://github.com/Dygerati/apollo-memory-leak
I’m using the pad here: https://launchpad.graphql.com/1xj5jr959
My github example will automatically create a heap snapshot in the directory every 10 minutes. After you let it run a bit, just load a couple snapshots into Chrome Dev Tools and set to compare. You should see a couple listings at the very top that are associated with Apollo–the one I sent a screenshot of earlier, as well as this one: https://imgur.com/a/zun8z
Thanks!
Is this not just a memory leak by design? @hwillson what performance improvements are you referring to that would have solved this issue?
I haven’t been using Apollo for very long but the behavior I see in my app is that when using link state a record of every mutation gets inserted into the cache under the ROOT_MUTATION key and seem to stay there indefinitely. Is there some process that is supposed to periodically clear out old mutations?