Does Apollo client perform any garbage collection on watches?

I am working on a large app and have noticed performance degrade over time.

From inspecting the cache I can see over 20,000 watches in the cache:
InMemoryCache2 {watches: Set(21126), typenameDocumentCache: Map(286), txCount: 0, getFragmentDoc: ƒ, makeVar: ƒ, …}

The watches don’t appear to get garbage collected when the component that called useQuery is unmounted so the watches Set just increases in size over time.

Is this expected behaviour?

And is there way to remove watches on unmount, or trigger a garbage collect somehow?

Thanks

Hi @John_Davison :wave: thanks for posting! What version of @apollo/client are you using?

Hi @JeffAuriemma thanks for the quick response. We’re on "@apollo/client": "3.7.14"