question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory Leak caused by MutationStore?

See original GitHub issue

Intended 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
joelclimbsthingscommented, Oct 16, 2017

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!

1reaction
dcossoncommented, Dec 7, 2018

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found