Bug 1713100 - Move AvailableMemoryTracker::Init() back to NS_InitXPCOM. r=gsvelto

Bug 1711610 moved `AvailableMemoryTracker::Init()` from `NS_InitXPCOM` to `XRE_mainRun`,
but it caused memory degradation because `AvailableMemoryTracker` was no longer initialized
in the child processes.

I made that part for `nsAvailableMemoryWatcher` to cache the pref value in the earlier design,
but it's not needed at all in the current design because `nsAvailableMemoryWatcher` loads
a mirror value every time.

This patch reverts `AvailableMemoryTracker::Init()` back to `NS_InitXPCOM`.

Differential Revision: https://phabricator.services.mozilla.com/D116742
This commit is contained in:
Toshihito Kikuchi 2021-06-04 14:16:02 +00:00
Родитель f82be201dc
Коммит a2c93279d1
2 изменённых файлов: 2 добавлений и 5 удалений

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

@ -11,7 +11,6 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/AvailableMemoryTracker.h"
#include "mozilla/Components.h"
#include "mozilla/FilePreferences.h"
#include "mozilla/ChaosMode.h"
@ -5236,10 +5235,6 @@ nsresult XREMain::XRE_mainRun() {
}
#endif
// AvailableMemoryTracker needs to be initialized
// after prefs have been loaded.
mozilla::AvailableMemoryTracker::Init();
{
rv = appStartup->Run();
if (NS_FAILED(rv)) {

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

@ -85,6 +85,7 @@
#include "base/message_loop.h"
#include "mozilla/ipc/BrowserProcessSubThread.h"
#include "mozilla/AvailableMemoryTracker.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/CountingAllocatorBase.h"
#include "mozilla/UniquePtr.h"
@ -461,6 +462,7 @@ NS_InitXPCOM(nsIServiceManager** aResult, nsIFile* aBinDirectory,
mozilla::SharedThreadPool::InitStatics();
mozilla::scache::StartupCache::GetSingleton();
mozilla::AvailableMemoryTracker::Init();
// Notify observers of xpcom autoregistration start
NS_CreateServicesFromCategory(NS_XPCOM_STARTUP_CATEGORY, nullptr,