You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
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).
<html><head><linkrel="stylesheet" href="./codemirror-5.57.0/lib/codemirror.css"><scriptsrc="./codemirror-5.57.0/lib/codemirror.js"></script></head><body><textareaid="targetTextarea" cols="30" rows="10"></textarea><br><br><divid="add">add and remove 1000</div><script>letcodemirror=undefined;lettargetTextareaEl=undefined;letadd=undefined;window.onload=function(){targetTextareaEl=document.querySelector('#targetTextarea');addEl=document.querySelector('#add');addEl.addEventListener('click',()=>{for(leti=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.
Thanks for the more detailed script, and sorry for closing so quickly before (I have wasted a lot of time on incorrect memory leak claims in the past, which has soured me a bit on the subject).
But indeed, I can reproduce this now. The problem was indeed related to the autofocus, which caused a focus flag to be set even though the editor wasn't actually focused. That, in turn, led to the editor not firing a blur event when removed from the DOM, which caused the cursor blink interval to continue firing forever.
Activity
marijnh commentedon Sep 11, 2020
Thanks for the more detailed script, and sorry for closing so quickly before (I have wasted a lot of time on incorrect memory leak claims in the past, which has soured me a bit on the subject).
But indeed, I can reproduce this now. The problem was indeed related to the
autofocus, which caused a focus flag to be set even though the editor wasn't actually focused. That, in turn, led to the editor not firing a blur event when removed from the DOM, which caused the cursor blink interval to continue firing forever.Update/5.58.2 (#1)
Fix bug causing a deleted editor to continue believing it had focus