зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1432901 - Part 12: Break cycles manually during shutdown r=yulia
Since mozJSComponentLoader is destroyed after the cycle collector, we need to break cycles manually before the final cycle collection otherwise we get a memory leak. Unload() is called at an appropriate earlier point in shutdown. Differential Revision: https://phabricator.services.mozilla.com/D145567
This commit is contained in:
Родитель
aed536664b
Коммит
10fc79714b
|
@ -873,6 +873,14 @@ ModuleLoaderBase::~ModuleLoaderBase() {
|
|||
LOG(("ModuleLoaderBase::~ModuleLoaderBase %p", this));
|
||||
}
|
||||
|
||||
void ModuleLoaderBase::Shutdown() {
|
||||
MOZ_ASSERT(mFetchingModules.IsEmpty());
|
||||
mFetchedModules.Clear();
|
||||
mGlobalObject = nullptr;
|
||||
mEventTarget = nullptr;
|
||||
mLoader = nullptr;
|
||||
}
|
||||
|
||||
bool ModuleLoaderBase::HasPendingDynamicImports() const {
|
||||
return !mDynamicImportRequests.isEmpty();
|
||||
}
|
||||
|
|
|
@ -180,6 +180,9 @@ class ModuleLoaderBase : public nsISupports {
|
|||
nsISerialEventTarget* aEventTarget =
|
||||
mozilla::GetMainThreadSerialEventTarget());
|
||||
|
||||
// Called to break cycles during shutdown to prevent memory leaks.
|
||||
void Shutdown();
|
||||
|
||||
using LoadedScript = JS::loader::LoadedScript;
|
||||
using ScriptFetchOptions = JS::loader::ScriptFetchOptions;
|
||||
using ScriptLoadRequest = JS::loader::ScriptLoadRequest;
|
||||
|
|
|
@ -475,6 +475,11 @@ void mozJSComponentLoader::InitStatics() {
|
|||
void mozJSComponentLoader::Unload() {
|
||||
if (sSelf) {
|
||||
sSelf->UnloadModules();
|
||||
|
||||
if (sSelf->mModuleLoader) {
|
||||
sSelf->mModuleLoader->Shutdown();
|
||||
sSelf->mModuleLoader = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче