jotai: Issue: atom get memory leak when using SSR
Next.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
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 25 (10 by maintainers)
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()