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

Memory leak when enter text using the fromTextArea #6409

Closed
RyuDoizaki opened this issue Sep 11, 2020 · 1 comment
Closed

Memory leak when enter text using the fromTextArea #6409

RyuDoizaki opened this issue Sep 11, 2020 · 1 comment

Comments

@RyuDoizaki
Copy link

Entering text using fromTextArea seems to cause a memory leak.

I checked this in Chrome.

Video showing the memory leak.

memory_leak

Source Code.

<html>
    <head>
        <link rel="stylesheet" href="./codemirror-5.57.0/lib/codemirror.css">
        <script src="./codemirror-5.57.0/lib/codemirror.js"></script>
    </head>
    <body>
        <textarea id="targetTextarea" cols="30" rows="10"></textarea>
        <br><br><div id="add">codemirror add</div>
        <br><div id="remove">codemirror remove</div>
        <script>
            let codemirror = undefined;
            let targetTextareaEl = undefined;
            let addEl = undefined;
            let removeEl = undefined;
            window.onload = function(){
                targetTextareaEl = document.querySelector('#targetTextarea');
                addEl = document.querySelector('#add');
                removeEl = document.querySelector('#remove');

                addEl.addEventListener('click', () => {
                    if(!codemirror) {
                        codemirror = CodeMirror.fromTextArea(targetTextareaEl);
                    }
                });
                removeEl.addEventListener('click', () => {
                    if(codemirror){
                        codemirror.toTextArea();
                    }
                    codemirror = undefined;
                });
            }
        </script>
    </body>
</html>

Adding characters by paste or deleting characters by delete key did not leak the memory

@marijnh
Copy link
Member

marijnh commented Sep 11, 2020

I can't reproduce this (pressing the garbage can icon takes the memory down the original level for me). If you can write a script that automatically, in a loop, causes significant amounts of extra memory to be consumed in a way that doesn't allow collecting, I'd be interested to take a look. But as it is, this doesn't give me enough to work with.

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