Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Memory Leak when rerendering CodeMirror #484

Open
humpalum opened this issue Apr 6, 2023 · 2 comments
Open

BUG: Memory Leak when rerendering CodeMirror #484

humpalum opened this issue Apr 6, 2023 · 2 comments

Comments

@humpalum
Copy link

humpalum commented Apr 6, 2023

Hey yall,

I think i found a memory leak in the CodeMirror Component...

You can find the PoC in the following Codesandbox:

CAREFUL: It will fill up your memory in just few minutes...
I used a quite small interval as well as many CodeMirror to speed up the process...

https://codesandbox.io/s/gallant-danilo-nc8euu?file=/src/App.js

Memory usage:
image
~1 min later:
image

It seems like Firefox is more affected by this than Chrome.. Chromes memory fills up way slower...

The workaround that i use is the following:
Instead of:

<CodeMirror
   theme={theme.colorScheme}
   height="500px"
   value={originalFilters}
   //defaultValue={originalFilters}
   placeholder={placeholder}
   onChange={setCurrentFilters}
   readOnly={readOnly}
 />

I use a memo:

<CodeMirrorMemo
  theme={theme.colorScheme}
  height="500px"
  value={originalFilters}
   //defaultValue={originalFilters}
  placeholder={placeholder}
   onChange={setCurrentFilters}
   readOnly={readOnly}
  
                />
                
const CodeMirrorMemo = memo(CodeMirror)

I'm not sure what else i could provide right now but feel free to request whatever else i can provide to help out. Thank you :)

@humpalum
Copy link
Author

humpalum commented Apr 6, 2023

Might be related to codemirror/dev#1070 ?

@jaywcjlove
Copy link
Member

@humpalum I can't solve this problem. If there is any optimization direction in the future, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants