Issue: atom get memory leak when using SSR
See original GitHub issueNext.js is in use, and the test applied filter() to atom get. For the test, 600 requests were sent for 1 minute.
version next 12.2.2 react 17.0.2 jotai 1.7.6
testing tool: k6
const options = {
stages: [
{ duration: "1m", target: 600 },
{ duration: "1m", target: 600 },
{ duration: "1m", target: 600 },
{ duration: "1m", target: 600 },
{ duration: "1m", target: 600 },
],
};
Test
// _app.js
return (
<Provider>
<Component {...pageProps} />
</Provider>
)
// component
const [readData] = useAtom(readDataAtom);
return (
<div>
<div>{JSON.stringify(readData)}</div>
</div>
);
// store
export const readDataAtom = atom((get) => {
return get(dataAtom).modules.filter(({ moduleSeq }, i) => moduleSeq > i + 210);
});
Result
It started at 153 MB, but it is 269 MB even after 5 minutes. Why is there a memory leak? I want help. thanks
Issue Analytics
- State:
- Created a year ago
- Comments:25 (10 by maintainers)
Top Results From Across the Web
Memory leak when using atomFamily/selectorFamily #366
Hello there,. The resources created by atomFamily and selectorFamily are not being properly freed when the specific key changes or if the ...
Read more >Learn How to Debug the Cause of Memory Leak in SSR
After migrating to SSR, just found out there was a memory leak. I believe it is a really good opportunity to face lots...
Read more >Hunting memory leaks in a server side rendered React ...
Our memory leak was caused by reselect and with the bad usage of styled-components, both problems were found by using Chrome DevTools. Backstory....
Read more >Question: Atom server memory leaks - Boomi Community
we are facing memory leaks issue ,. we have 15 GB RAM for Atom server, but its usage increasing daily 3GB when it...
Read more >Memory Leaking Scenarios - Go 101
When programming in a language supporting auto garbage collection, generally we don't need care about memory leaking problems, for the runtime will collect ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
right! I think it’s a problem with next.js.
Thanks for helping with testing, and thanks for making jotai. I will use it well!
@dai-shi yes! I use .filter()