From 88e6face01795b161523824ba075444fad55466a Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Fri, 10 Jan 2025 18:15:49 +0100 Subject: [PATCH] chore - remove listener "GC'ed before dispose" tracking because we now have this for all disposables (#237656) --- src/vs/base/common/event.ts | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/src/vs/base/common/event.ts b/src/vs/base/common/event.ts index d49f2ef276f47..fe10aaf1c8926 100644 --- a/src/vs/base/common/event.ts +++ b/src/vs/base/common/event.ts @@ -13,12 +13,6 @@ import { IObservable, IObservableWithChange, IObserver } from './observable.js'; import { StopWatch } from './stopwatch.js'; import { MicrotaskDelay } from './symbols.js'; -// ----------------------------------------------------------------------------------------------------------------------- -// Uncomment the next line to print warnings whenever a listener is GC'ed without having been disposed. This is a LEAK. -// ----------------------------------------------------------------------------------------------------------------------- -const _enableListenerGCedWarning = false - // || Boolean("TRUE") // causes a linter warning so that it cannot be pushed - ; // ----------------------------------------------------------------------------------------------------------------------- // Uncomment the next line to print warnings whenever an emitter with listeners is disposed. That is a sign of code smell. @@ -984,28 +978,6 @@ const forEachListener = (listeners: ListenerOrListeners, fn: (c: ListenerC } }; - -let _listenerFinalizers: FinalizationRegistry | undefined; - -if (_enableListenerGCedWarning) { - const leaks: string[] = []; - - setInterval(() => { - if (leaks.length === 0) { - return; - } - console.warn('[LEAKING LISTENERS] GC\'ed these listeners that were NOT yet disposed:'); - console.warn(leaks.join('\n')); - leaks.length = 0; - }, 3000); - - _listenerFinalizers = new FinalizationRegistry(heldValue => { - if (typeof heldValue === 'string') { - leaks.push(heldValue); - } - }); -} - /** * The Emitter can be used to expose an Event to the public * to fire it from the insides. @@ -1161,7 +1133,6 @@ export class Emitter { const result = toDisposable(() => { - _listenerFinalizers?.unregister(result); removeMonitor?.(); this._removeListener(contained); }); @@ -1171,12 +1142,6 @@ export class Emitter { disposables.push(result); } - if (_listenerFinalizers) { - const stack = new Error().stack!.split('\n').slice(2, 3).join('\n').trim(); - const match = /(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(stack); - _listenerFinalizers.register(result, match?.[2] ?? stack, result); - } - return result; };