-
Notifications
You must be signed in to change notification settings - Fork 39.3k
Possible memory leak in debounce #279177
Copy link
Copy link
Open
Labels
bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bugfreeze-slow-crash-leakVS Code crashing, performance, freeze and memory leak issuesVS Code crashing, performance, freeze and memory leak issuesterminal-processProblems launching processes, managing ptys, exiting, process leaks, etc.Problems launching processes, managing ptys, exiting, process leaks, etc.
Milestone
Metadata
Metadata
Assignees
Labels
bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bugfreeze-slow-crash-leakVS Code crashing, performance, freeze and memory leak issuesVS Code crashing, performance, freeze and memory leak issuesterminal-processProblems launching processes, managing ptys, exiting, process leaks, etc.Problems launching processes, managing ptys, exiting, process leaks, etc.
Does this issue occur when all extensions are disabled?: Yes
From #279172:
When running a task 17 times, the number of objects / functions seems to increase at these specific locations:
{ "namedFunctionCount3": [ { "count": 20, "delta": 17, "name": "ChildProcessMonitor", "sourceLocation": "vscode/out/vs/platform/terminal/node/childProcessMonitor.js:24:13", "originalLocation": "src/vs/platform/terminal/node/childProcessMonitor.ts:52:19", "originalName": "ChildProcessMonitor" }, { "count": 19, "delta": 17, "name": "anonymous", "sourceLocation": "vscode/out/vs/base/common/decorators.js:59:34", "originalLocation": "src/vs/base/common/decorators.ts:83:31", "originalName": "debounce" } ], "isLeak": true }Debounce function:
Looking at the debounce function, it stores the result of the function as
$debounce$result$${key}. It could be a problem if the reducer function is async and returns a promise that depends on the class, creating a sort of cyclic dependency between them which prevents garbage collectionSome ideas
result instanceof Promiseand then not storing itthisis aDisposableand register a function to it that clears the stored debounce results when the class instance gets diposed