question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue: atom get memory leak when using SSR

See original GitHub issue

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

jotai_get-selector-atom

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:closed
  • Created a year ago
  • Comments:25 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
leedoopalcommented, Sep 12, 2022

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!

1reaction
leedoopalcommented, Sep 2, 2022

@dai-shi yes! I use .filter()

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found