Replies: 4 comments 1 reply
-
|
looks like the queryClient is created outside of the component / request scope and thus sticks around |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for your response. npm run build
npm run start:memory-test
for i in {1..500}; do curl http://localhost:3000/ko; doneWhen the gcTime of the useUsers hook is 0, no error occurs, but when it's not 0, a JS OOM issue occurs.
project : https://github.com/hovelopin/gctime-oom |
Beta Was this translation helpful? Give feedback.
-
|
After checking, it seems the problem only occurs when used together with the |
Beta Was this translation helpful? Give feedback.
-
|
Hi, we had a similar issue, where the queryClient had gcTime: Infinity, and some queries were prefetched server side. Then some other query - only loaded client side with useQuery - further down in the component tree had a gcTime set to 24h. timers -> query with set gcTime -> queryclient -> [all other queries prefetched with default Infinity gcTime]. The queryClient is created with cache() so that it is unique per request. The fix was to either
Maybe unrelated, but sharing because we spent quite some time digging into the heap dumps trying to understand what was happening. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
I encountered a memory issue in my Next.js project, and the cause was the gcTime configuration.
When I removed the existing 24-hour gcTime setting or changed it to 0, the memory leak was resolved, but I don't understand why.
From what I know, gcTime is set to Infinity by default in Next.js server environments, so it seems like memory wouldn't be released and should cause problems, but that wasn't the case. What could be the issue here?
For testing, I repeatedly sent curl requests to the suspected page and confirmed JS OOM errors. After removing code piece by piece to track down the cause, I was able to resolve the issue by changing the gcTime setting value.
Beta Was this translation helpful? Give feedback.
All reactions