Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.

Possible memory leak in query cache #26

Closed
tlgimenes opened this issue Sep 19, 2018 · 0 comments · Fixed by #29
Closed

Possible memory leak in query cache #26

tlgimenes opened this issue Sep 19, 2018 · 0 comments · Fixed by #29
Labels
blocking Prevents production or dev due to perf, bug, build error, etc.. bug memory leak

Comments

@tlgimenes
Copy link

Hello guys !

I'm currently developing a GraphQL hub that serves as a proxy to many other GraphQL servers. These servers accept persisted queries and I thought it would be really nice to use this package for sending them hashed queries. However, after some time in production, my GraphQL hub started running out of memory. After much investigation, our team found out that this package was the evil of our memory leak.

The leak occurs because this package tries to optimize the query computation by using a Map as a cache, and this map grows indefinitely. leak

My fix proposal is to accept a cache implementation with the interface defined by apollo-server-caching so we can use the cache implementation that best fits our needs (with Map as the default value for this cache)

What do you guys think ?

Thank you !

@ghost ghost added blocking Prevents production or dev due to perf, bug, build error, etc.. bug memory leak labels Sep 19, 2018
benjamn added a commit that referenced this issue Oct 22, 2018
Should fix #26, since the hash can now be garbage collected whenever the
query object is collected, and query objects are no longer kept alive by
the calculated Map.
benjamn added a commit that referenced this issue Oct 22, 2018
. (#29)

* Replace Map-based cache of query hashes with private property.

Should fix #26, since the hash can now be garbage collected whenever the
query object is collected, and query objects are no longer kept alive by
the calculated Map.

* Bump max bundle size to make Travis tests pass.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocking Prevents production or dev due to perf, bug, build error, etc.. bug memory leak
Projects
None yet
1 participant