Skip to content
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

scope canonicalStringify to a cache instance #11255

Closed
wants to merge 2 commits into from

Conversation

phryneas
Copy link
Member

In the context of #11242 I'm looking into potential memory leaks (with focus on SSR), and something that has come up multiple times in issues is that canonicalStringify just keeps growing for people, even if an ApolloClient instance is discarded.

One possible solution for that is #11254, this is yet another suggestion for a fix - I want to build a package and test this locally.

Checklist:

  • If this PR contains changes to the library itself (not necessary for e.g. docs updates), please include a changeset (see CONTRIBUTING.md)
  • If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests

@changeset-bot
Copy link

changeset-bot bot commented Sep 27, 2023

🦋 Changeset detected

Latest commit: 0d3cdde

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@apollo/client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@phryneas
Copy link
Member Author

/release:pr

@github-actions
Copy link
Contributor

A new release has been made for this PR. You can install it with npm i @apollo/[email protected].

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
dist/apollo-client.min.cjs 37.16 KB (+0.19% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" 43.51 KB (+0.17% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" (production) 42.06 KB (+0.19% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" 32.61 KB (+0.25% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" (production) 31.34 KB (+0.24% 🔺)
import { ApolloProvider } from "dist/react/index.js" 1.21 KB (0%)
import { ApolloProvider } from "dist/react/index.js" (production) 1.2 KB (0%)
import { useQuery } from "dist/react/index.js" 4.27 KB (0%)
import { useQuery } from "dist/react/index.js" (production) 4.08 KB (0%)
import { useLazyQuery } from "dist/react/index.js" 4.58 KB (0%)
import { useLazyQuery } from "dist/react/index.js" (production) 4.4 KB (0%)
import { useMutation } from "dist/react/index.js" 2.52 KB (0%)
import { useMutation } from "dist/react/index.js" (production) 2.51 KB (0%)
import { useSubscription } from "dist/react/index.js" 2.24 KB (0%)
import { useSubscription } from "dist/react/index.js" (production) 2.2 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" 4.64 KB (+1.07% 🔺)
import { useSuspenseQuery } from "dist/react/index.js" (production) 4.08 KB (+1.46% 🔺)
import { useBackgroundQuery } from "dist/react/index.js" 4.15 KB (+1.22% 🔺)
import { useBackgroundQuery } from "dist/react/index.js" (production) 3.58 KB (+1.59% 🔺)
import { useReadQuery } from "dist/react/index.js" 2.96 KB (0%)
import { useReadQuery } from "dist/react/index.js" (production) 2.91 KB (0%)
import { useFragment } from "dist/react/index.js" 2.08 KB (0%)
import { useFragment } from "dist/react/index.js" (production) 2.03 KB (0%)

@phryneas
Copy link
Member Author

Looking at heap dumps, #11254 is the way to go here, and scoping to a client instance might not be necessary in the first place - at least with the benchmarks I have right now.

I might revisit this approach in combination with #11254 if further benchmarks show a need for it, but for now I'll close the PR.

@phryneas phryneas closed this Sep 27, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 28, 2023
@phryneas phryneas added this to the MemoryAnalysis milestone Nov 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant