Bug 1735024 - [devtools] Fix the leaks from firefox data provider r=ochameau

Fixes the leaks of the cached stacktrace info in stackTraceInfoByActorID.
Prior to this fix, the stacktrace info in the cache is only removed when the stacktrace
details panel is opened, meaning if the details panel is never opened the
info is never cleared and leaks.
This fixes the netmonitor and the webconsole as they both use the data provider

### Leak Info

####  Netmonitor
Before: 151 leaked objects (14611 with missing allocation site) in the parent process
After: -111 leaked objects (14150 with missing allocation site) in the parent process

#### Webconsole
Before: 271 leaked objects (13996 with missing allocation site) in the parent process
After: 1 leaked objects (13810 with missing allocation site) in the parent process

Differential Revision: https://phabricator.services.mozilla.com/D128015
This commit is contained in:
Hubert Boma Manilla 2021-10-22 10:43:34 +00:00
Родитель 7e2565109e
Коммит 2f8a28d28d
4 изменённых файлов: 21 добавлений и 0 удалений

Просмотреть файл

@ -76,6 +76,18 @@ class FirefoxDataProvider {
this.onEventReceived = this.onEventReceived.bind(this);
this.setEventStreamFlag = this.setEventStreamFlag.bind(this);
}
/*
* Cleans up all the internal states, this usually done before navigation
* (without the persist flag on), or just before the data provider is
* nulled out.
*/
destroy() {
this.stackTraces.clear();
this.pendingRequests.clear();
this.lazyRequestData.clear();
this.stackTraceRequestInfoByActorID.clear();
}
/**
* Enable/disable firing redux actions (enabled by default).

Просмотреть файл

@ -171,6 +171,8 @@ class Connector {
}
this.webConsoleFront = null;
this.dataProvider.destroy();
this.dataProvider = null;
}
@ -296,6 +298,8 @@ class Connector {
if (!Services.prefs.getBoolPref(DEVTOOLS_ENABLE_PERSISTENT_LOG_PREF)) {
this.actions.batchReset();
this.actions.clearRequests();
// clean up all the dataProvider internal state
this.dataProvider.destroy();
} else {
// If the log is persistent, just clear all accumulated timing markers.
this.actions.clearTimingMarkers();

Просмотреть файл

@ -240,6 +240,9 @@ class WebConsoleUI {
this.proxy = null;
this.additionalProxies = null;
this.networkDataProvider.destroy();
this.networkDataProvider = null;
// Nullify `hud` last as it nullify also target which is used on destroy
this.window = this.hud = this.wrapper = null;
}

Просмотреть файл

@ -154,6 +154,8 @@ class WebConsoleWrapper {
);
store?.dispatch(actions.messagesClear());
// cleans up all the network data provider internal state
this.webConsoleUI.networkDataProvider.destroy();
this.webConsoleUI.emitForTests("messages-cleared");
}