-
Notifications
You must be signed in to change notification settings - Fork 37.2k
fix: memory leak in linkDetector #280204
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
base: main
Are you sure you want to change the base?
fix: memory leak in linkDetector #280204
Conversation
connor4312
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
|
Build error: |
Head branch was pushed to by a user without write access
38fda63
|
Thanks!
It should be good to go now! |
|
thanks! |
|
Looks like something in the tests might be missing a disposable check 😬 |
Head branch was pushed to by a user without write access
c766088
|
Thanks!
/* Since this is async. when the promise resolves, the store might be disposed */
this.fileService.stat(uri).then(stat => {
if (stat.isDirectory) {
return;
}
this.decorateLink(link, uri, fulltext, hoverBehavior, (preserveFocus: boolean) => this.editorService.openEditor({ resource: uri, options: { ...options, preserveFocus } }));
} |
Fixes a memory leak in
linkDetector.tsby replacingHTMLElement.onclickwithdom.addDisposableListener('click').Because of that, now the disposable store also needs to be passed from one function to another and another. But the main change is replacing
HTMLElement.onclickwithdom.addDisposableListener('click').Test Results
Before
A
keydown,click,mouseleaveandmousemoveevent listener leak related tolinkDetectorare found:{ "eventListenersWithStackTrace": [ { "type": "keydown", "description": "l=>{const c=new Li(l);(c.keyCode===3||c.keyCode===10)&&(c.preventDefault(),c.stopPropagation(),r(c.keyCode===10))}", "objectId": "-6136671504294265107.1.22263", "count": 133, "originalStack": ["src/vs/workbench/contrib/debug/browser/linkDetector.ts:338:19"], "originalName": "e" }, { "type": "click", "description": "l=>{const c=Te(e).getSelection();!c||c.type===\"Range\"||(Ye?l.metaKey:l.ctrlKey)&&(l.preventDefault(),l.stopImmediatePropagation(),r(!1))}", "objectId": "-6136671504294265107.1.22261", "count": 133, "originalStack": ["src/vs/workbench/contrib/debug/browser/linkDetector.ts:325:18"], "originalName": "event" }, { "type": "mouseleave", "description": "()=>e.classList.remove(\"pointer\")", "objectId": "-6136671504294265107.1.22259", "count": 133, "originalStack": ["src/vs/workbench/contrib/debug/browser/linkDetector.ts:324:22"], "originalName": null }, { "type": "mousemove", "description": "l=>{e.classList.toggle(\"pointer\",Ye?l.metaKey:l.ctrlKey)}", "objectId": "-6136671504294265107.1.22257", "count": 133, "originalStack": ["src/vs/workbench/contrib/debug/browser/linkDetector.ts:323:22"], "originalName": "event" } ], "isLeak": true }After
No more leak is detected.