Skip to content

Memory leak when using fromTextArea #6410

@RyuDoizaki

Description

@RyuDoizaki

I found a memory leak but the issue was rejected due to lack of explanation.
#6409

In the previous issue, I explained that entering characters is a condition for memory leaks. But, I found that it can be reproduced simply by setting it to {autoFocus: true}.
Just by repeating fromTextArea and toTextArea, garbage will be accumulated in the memory.
These are not deleted when you run garbage collection (press the trash can icon).

memory_leak2

<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">add and remove 1000</div>
        <script>
            let codemirror = undefined;
            let targetTextareaEl = undefined;
            let add = undefined;

            window.onload = function(){
                targetTextareaEl = document.querySelector('#targetTextarea');
                addEl = document.querySelector('#add');
                addEl.addEventListener('click', () => {
                    for (let i = 0; i < 1000; i++) {
                        codemirror = CodeMirror.fromTextArea(targetTextareaEl, { autofocus: true });
                        codemirror.toTextArea();
                    }
                    codemirror = undefined;
                });
            }
        </script>
    </body>
</html>

I think this is a big problem for Single Page Application.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions