Memory leak
See original GitHub issueI’m sure an example can be simplified, but somewhere between 0.0.7 and 0.0.10 memory leak were introduced.
import React from "react";
import { RecoilRoot, useSetRecoilState, atom, useRecoilValue } from "recoil";
const state = atom({
key: "test",
default: []
});
const Subscriber = () => {
const setTest = useSetRecoilState(state);
React.useEffect(() => {
const u = old => {
const item = Math.random();
if (old.length >= 5000) {
return [item, ...old.slice(0, -1)];
} else {
return [item, ...old];
}
};
const t = () => setTest(u);
setInterval(t, 10);
}, []);
return null;
};
const Test = () => {
const test = useRecoilValue(state);
return <div>{test.length}</div>;
};
export default function App() {
console.log("render");
return (
<RecoilRoot>
<Subscriber />
<Test />
</RecoilRoot>
);
}
Codesandbox:
0.0.10: code, demo
0.0.7: code, demo
Sandbox with 0.0.7 version doesn’t have memory leak, as you might see here (app run about 2 minutes between heap snapshots).
0.0.10:
0.0.7:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:16 (6 by maintainers)
Top Results From Across the Web
Memory leak - Wikipedia
In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in...
Read more >What is Memory Leak? How can we avoid? - GeeksforGeeks
Memory leak occurs when programmers create a memory in heap and forget to delete it. The consequences of memory leak is that it...
Read more >Definition of memory leak - PCMag
When memory is allocated, but not deallocated, a memory leak occurs (the memory has leaked out of the computer). If too many memory...
Read more >Memory leak - OWASP Foundation
A memory leak is an unintentional form of memory consumption whereby the developer fails to free an allocated block of memory when no...
Read more >Find a memory leak - Windows drivers - Microsoft Learn
A memory leak occurs when a process allocates memory from the paged or nonpaged pools, but doesn't free the memory.
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
We’re finalizing some changes for Concurrent Mode now, then can try to investigate this before the next release.
@saltycrane - Thank you for the reproducer.