Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

Memory leak when enter text using the fromTextArea #6409

Closed

Description

@RyuDoizaki

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

Activity

  1. marijnh commented on Sep 11, 2020

    @marijnh
    Member

    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

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