2013-01-18 09:43:21 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-12-15 23:48:38 +04:00
|
|
|
|
|
|
|
#include "mozilla/AvailableMemoryTracker.h"
|
2012-11-12 20:41:23 +04:00
|
|
|
|
2013-09-19 22:29:31 +04:00
|
|
|
#if defined(XP_WIN)
|
Bug 1733308 - Fix non-unified builds errors in xpcom/base. r=xpcom-reviewers,mccr8
objdir/dist/include/mozilla/DeferredFinalize.h:30:1: error: unknown type name 'MOZ_NEVER_INLINE'
objdir/dist/include/mozilla/dom/BindingUtils.h:2776:5: error: no matching function for call to 'DeferredFinalize'
xpcom/base/AvailableMemoryTracker.cpp:55,40:: error: expected class name
xpcom/base/AvailableMemoryTracker.cpp:59,3:: error: 'AddRef' marked 'override' but does not override any member functions
xpcom/base/AvailableMemoryTracker.cpp:59,3:: error: 'QueryInterface' marked 'override' but does not override any member functions
xpcom/base/AvailableMemoryTracker.cpp:59,3:: error: 'Release' marked 'override' but does not override any member functions
xpcom/base/AvailableMemoryTracker.cpp:61,29:: error: unknown type name 'nsIHandleReportCallback'
xpcom/base/AvailableMemoryTracker.cpp:65,37:: error: use of undeclared identifier 'KIND_OTHER'
xpcom/base/AvailableMemoryTracker.cpp:65,49:: error: use of undeclared identifier 'UNITS_COUNT_CUMULATIVE'
xpcom/base/AvailableMemoryTracker.cpp:77,1:: error: invalid application of 'sizeof' to an incomplete type 'const QITableEntry []'
xpcom/base/AvailableMemoryTracker.cpp:77,1:: error: static_cast from '(anonymous namespace)::LowEventsReporter *' to 'nsISupports *', which are not related by inheritance, is not allowed
xpcom/base/AvailableMemoryTracker.cpp:77,38:: error: unknown type name 'nsIMemoryReporter'
xpcom/base/AvailableMemoryTracker.cpp:77,38:: error: use of undeclared identifier 'nsIMemoryReporter'
xpcom/base/AvailableMemoryTracker.cpp:187,3:: error: use of undeclared identifier 'RegisterLowMemoryEventsPhysicalDistinguishedAmount'
xpcom/base/AvailableMemoryWatcherWin.cpp:31,47:: error: base class has incomplete type
xpcom/base/AvailableMemoryWatcherWin.cpp:37,3:: error: unknown type name 'NS_DECL_NSIOBSERVER'
xpcom/base/AvailableMemoryWatcherWin.cpp:38,3:: error: 'virtual' can only appear on non-static member functions
xpcom/base/AvailableMemoryWatcherWin.cpp:38,3:: error: expected ';' at end of declaration list
xpcom/base/AvailableMemoryWatcherWin.cpp:38,3:: error: static_assert failed due to requirement 'std::is_convertible<mozilla::nsAvailableMemoryWatcher *, nsINamed *>::value' "nsITimerCallback implementations must also implement nsINamed"
xpcom/base/AvailableMemoryWatcherWin.cpp:39,3:: error: must use 'enum' tag to refer to type 'nsresult' in this scope
xpcom/base/AvailableMemoryWatcherWin.cpp:42,3:: error: must use 'enum' tag to refer to type 'nsresult' in this scope
xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: cannot initialize object parameter of type 'mozilla::nsAvailableMemoryWatcherBase' with an expression of type 'mozilla::nsAvailableMemoryWatcher'
xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: invalid application of 'sizeof' to an incomplete type 'const QITableEntry []'
xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: must use 'enum' tag to refer to type 'nsresult' in this scope
xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: static_cast from 'mozilla::nsAvailableMemoryWatcher *' to 'nsINamed *', which are not related by inheritance, is not allowed
xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: static_cast from 'mozilla::nsAvailableMemoryWatcher *' to 'nsIObserver *', which are not related by inheritance, is not allowed
xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: static_cast from 'mozilla::nsAvailableMemoryWatcher *' to 'nsITimerCallback *', which are not related by inheritance, is not allowed
xpcom/base/AvailableMemoryWatcherWin.cpp:103,59:: error: 'nsIObserver' does not refer to a value
xpcom/base/AvailableMemoryWatcherWin.cpp:103,59:: error: incomplete type 'nsIObserver' named in nested name specifier
xpcom/base/AvailableMemoryWatcherWin.cpp:140,45:: error: cannot initialize a parameter of type 'nsIObserver *' with an rvalue of type 'mozilla::nsAvailableMemoryWatcher *'
xpcom/base/AvailableMemoryWatcherWin.cpp:140,5:: error: must use 'enum' tag to refer to type 'nsresult' in this scope
xpcom/base/CycleCollectedJSRuntime.cpp:1605,7:: error: use of undeclared identifier 'PR_GetEnv'
xpcom/base/CycleCollectedJSRuntime.cpp:1605:7: error: use of undeclared identifier 'PR_GetEnv'
xpcom/base/DeferredFinalize.cpp:12,15:: error: out-of-line definition of 'DeferredFinalize' does not match any declaration in namespace 'mozilla'
xpcom/base/DeferredFinalize.cpp:12:15: error: out-of-line definition of 'DeferredFinalize' does not match any declaration in namespace 'mozilla'
xpcom/base/MemoryTelemetry.cpp:48,27:: error: unused variable 'kTotalMemoryCollectorTimeout' [-Werror,-Wunused-const-variable]
xpcom/base/MemoryTelemetry.cpp:48:27: error: unused variable 'kTotalMemoryCollectorTimeout' [-Werror,-Wunused-const-variable]
xpcom/base/nsErrorService.cpp:42,21:: error: use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension [-Werror,-Wc++20-extensions]
xpcom/base/nsErrorService.cpp:42,21:: error: use of undeclared identifier 'MakeUnique'; did you mean 'mozilla::MakeUnique'?
xpcom/base/nsErrorService.cpp:42:21: error: use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension [-Werror,-Wc++20-extensions]
xpcom/base/nsErrorService.cpp:42:21: error: use of undeclared identifier 'MakeUnique'; did you mean 'mozilla::MakeUnique'?
xpcom/base/nsMacPreferencesReader.mm:20:12: error: implicit instantiation of undefined template 'nsTSubstring<char16_t>'
xpcom/base/nsMacPreferencesReader.mm:24:60: error: use of undeclared identifier 'NSString'
xpcom/base/nsMacPreferencesReader.mm:24:69: error: expected expression
xpcom/base/nsMacPreferencesReader.mm:26:48: error: unknown type name 'NSArray'
xpcom/base/nsMacPreferencesReader.mm:28:30: error: use of undeclared identifier 'NSString'
xpcom/base/nsMacPreferencesReader.mm:29:30: error: no matching function for call to 'MakeStringSpan'
xpcom/base/nsMacPreferencesReader.mm:29:51: error: instance method '-UTF8String' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access]
xpcom/base/nsMacPreferencesReader.mm:30:22: error: instance method '-isKindOfClass:' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access]
xpcom/base/nsMacPreferencesReader.mm:30:37: error: receiver type 'int (*)(int)' is not 'id' or interface pointer, consider casting it to 'id' [-Werror,-Wreceiver-expr]
xpcom/base/nsMacPreferencesReader.mm:30:37: error: use of undeclared identifier 'NSNumber'; did you mean 'isnumber'?
xpcom/base/nsMacPreferencesReader.mm:30:46: error: instance method '-class' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access]
xpcom/base/nsMacPreferencesReader.mm:31:27: error: cannot initialize a parameter of type 'int64_t' (aka 'long long') with an rvalue of type 'id'
xpcom/base/nsMacPreferencesReader.mm:31:33: error: instance method '-longLongValue' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access]
xpcom/base/nsMacPreferencesReader.mm:32:37: error: use of undeclared identifier 'NSArray'
xpcom/base/nsMacPreferencesReader.mm:34:7: error: no matching function for call to 'EvaluateArray'
xpcom/base/nsMacPreferencesReader.mm:36:37: error: use of undeclared identifier 'NSDictionary'
xpcom/base/nsMacPreferencesReader.mm:38:7: error: no matching function for call to 'EvaluateDict'
xpcom/base/nsMacPreferencesReader.mm:44:60: error: use of undeclared identifier 'NSString'
xpcom/base/nsMacPreferencesReader.mm:44:69: error: expected expression
xpcom/base/nsSystemInfo.cpp:415,35:: error: no template named 'NotNull'; did you mean 'NonNull'?
xpcom/base/nsSystemInfo.cpp:419,25:: error: member reference type 'NonNull<IWSCProductList *>' is not a pointer; did you mean to use '.'?
xpcom/base/nsSystemInfo.cpp:419,27:: error: no member named 'get_Count' in 'mozilla::dom::NonNull<IWSCProductList *>'
xpcom/base/nsSystemInfo.cpp:426,19:: error: member reference type 'NonNull<IWSCProductList *>' is not a pointer; did you mean to use '.'?
xpcom/base/nsSystemInfo.cpp:426,21:: error: no member named 'get_Item' in 'mozilla::dom::NonNull<IWSCProductList *>'
xpcom/base/nsSystemInfo.cpp:484,17:: error: use of undeclared identifier 'ArrayLength'; did you mean 'mozilla::ArrayLength'?
xpcom/base/nsSystemInfo.cpp:484,47:: error: use of undeclared identifier 'ArrayLength'; did you mean 'mozilla::ArrayLength'?
xpcom/base/nsSystemInfo.cpp:487,36:: error: use of undeclared identifier 'ArrayLength'; did you mean 'mozilla::ArrayLength'?
xpcom/base/nsSystemInfo.cpp:500,10:: error: no matching function for call to 'EnumWSCProductList'
xpcom/base/nsSystemInfo.cpp:500,46:: error: use of undeclared identifier 'WrapNotNull'; did you mean 'mozilla::WrapNotNull'?
xpcom/base/nsTraceRefcnt.cpp:313,32:: error: use of undeclared identifier 'MakeUnique'
xpcom/base/nsTraceRefcnt.cpp:313:32: error: use of undeclared identifier 'MakeUnique'
xpcom/base/nsTraceRefcnt.cpp:461,19:: error: no matching member function for call to 'WithEntryHandle'
xpcom/base/nsTraceRefcnt.cpp:461:19: error: no matching member function for call to 'WithEntryHandle'
xpcom/base/nsTraceRefcnt.cpp:468,33:: error: use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension [-Werror,-Wc++20-extensions]
xpcom/base/nsTraceRefcnt.cpp:468,33:: error: use of undeclared identifier 'MakeUnique'
xpcom/base/nsTraceRefcnt.cpp:468:33: error: use of undeclared identifier 'MakeUnique'
xpcom/base/nsTraceRefcnt.cpp:736,20:: error: use of undeclared identifier '_write'
Differential Revision: https://phabricator.services.mozilla.com/D127036
2021-10-01 04:49:16 +03:00
|
|
|
# include "nsIMemoryReporter.h"
|
2013-09-19 22:29:31 +04:00
|
|
|
#endif
|
|
|
|
|
2012-11-12 20:41:23 +04:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsIRunnable.h"
|
|
|
|
#include "nsISupports.h"
|
2013-09-19 22:29:31 +04:00
|
|
|
#include "nsThreadUtils.h"
|
2018-05-17 15:48:02 +03:00
|
|
|
#include "nsXULAppAPI.h"
|
2012-11-12 20:41:23 +04:00
|
|
|
|
2021-03-31 18:18:05 +03:00
|
|
|
#include "mozilla/Mutex.h"
|
2018-05-17 15:48:02 +03:00
|
|
|
#include "mozilla/ResultExtensions.h"
|
2012-11-12 20:41:23 +04:00
|
|
|
#include "mozilla/Services.h"
|
|
|
|
|
|
|
|
#if defined(MOZ_MEMORY)
|
2012-12-07 12:32:24 +04:00
|
|
|
# include "mozmemory.h"
|
2012-11-12 20:41:23 +04:00
|
|
|
#endif // MOZ_MEMORY
|
2011-12-15 23:48:38 +04:00
|
|
|
|
2011-12-19 20:57:57 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
Bug 1733308 - Fix non-unified builds errors in xpcom/base. r=xpcom-reviewers,mccr8
objdir/dist/include/mozilla/DeferredFinalize.h:30:1: error: unknown type name 'MOZ_NEVER_INLINE'
objdir/dist/include/mozilla/dom/BindingUtils.h:2776:5: error: no matching function for call to 'DeferredFinalize'
xpcom/base/AvailableMemoryTracker.cpp:55,40:: error: expected class name
xpcom/base/AvailableMemoryTracker.cpp:59,3:: error: 'AddRef' marked 'override' but does not override any member functions
xpcom/base/AvailableMemoryTracker.cpp:59,3:: error: 'QueryInterface' marked 'override' but does not override any member functions
xpcom/base/AvailableMemoryTracker.cpp:59,3:: error: 'Release' marked 'override' but does not override any member functions
xpcom/base/AvailableMemoryTracker.cpp:61,29:: error: unknown type name 'nsIHandleReportCallback'
xpcom/base/AvailableMemoryTracker.cpp:65,37:: error: use of undeclared identifier 'KIND_OTHER'
xpcom/base/AvailableMemoryTracker.cpp:65,49:: error: use of undeclared identifier 'UNITS_COUNT_CUMULATIVE'
xpcom/base/AvailableMemoryTracker.cpp:77,1:: error: invalid application of 'sizeof' to an incomplete type 'const QITableEntry []'
xpcom/base/AvailableMemoryTracker.cpp:77,1:: error: static_cast from '(anonymous namespace)::LowEventsReporter *' to 'nsISupports *', which are not related by inheritance, is not allowed
xpcom/base/AvailableMemoryTracker.cpp:77,38:: error: unknown type name 'nsIMemoryReporter'
xpcom/base/AvailableMemoryTracker.cpp:77,38:: error: use of undeclared identifier 'nsIMemoryReporter'
xpcom/base/AvailableMemoryTracker.cpp:187,3:: error: use of undeclared identifier 'RegisterLowMemoryEventsPhysicalDistinguishedAmount'
xpcom/base/AvailableMemoryWatcherWin.cpp:31,47:: error: base class has incomplete type
xpcom/base/AvailableMemoryWatcherWin.cpp:37,3:: error: unknown type name 'NS_DECL_NSIOBSERVER'
xpcom/base/AvailableMemoryWatcherWin.cpp:38,3:: error: 'virtual' can only appear on non-static member functions
xpcom/base/AvailableMemoryWatcherWin.cpp:38,3:: error: expected ';' at end of declaration list
xpcom/base/AvailableMemoryWatcherWin.cpp:38,3:: error: static_assert failed due to requirement 'std::is_convertible<mozilla::nsAvailableMemoryWatcher *, nsINamed *>::value' "nsITimerCallback implementations must also implement nsINamed"
xpcom/base/AvailableMemoryWatcherWin.cpp:39,3:: error: must use 'enum' tag to refer to type 'nsresult' in this scope
xpcom/base/AvailableMemoryWatcherWin.cpp:42,3:: error: must use 'enum' tag to refer to type 'nsresult' in this scope
xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: cannot initialize object parameter of type 'mozilla::nsAvailableMemoryWatcherBase' with an expression of type 'mozilla::nsAvailableMemoryWatcher'
xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: invalid application of 'sizeof' to an incomplete type 'const QITableEntry []'
xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: must use 'enum' tag to refer to type 'nsresult' in this scope
xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: static_cast from 'mozilla::nsAvailableMemoryWatcher *' to 'nsINamed *', which are not related by inheritance, is not allowed
xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: static_cast from 'mozilla::nsAvailableMemoryWatcher *' to 'nsIObserver *', which are not related by inheritance, is not allowed
xpcom/base/AvailableMemoryWatcherWin.cpp:102,1:: error: static_cast from 'mozilla::nsAvailableMemoryWatcher *' to 'nsITimerCallback *', which are not related by inheritance, is not allowed
xpcom/base/AvailableMemoryWatcherWin.cpp:103,59:: error: 'nsIObserver' does not refer to a value
xpcom/base/AvailableMemoryWatcherWin.cpp:103,59:: error: incomplete type 'nsIObserver' named in nested name specifier
xpcom/base/AvailableMemoryWatcherWin.cpp:140,45:: error: cannot initialize a parameter of type 'nsIObserver *' with an rvalue of type 'mozilla::nsAvailableMemoryWatcher *'
xpcom/base/AvailableMemoryWatcherWin.cpp:140,5:: error: must use 'enum' tag to refer to type 'nsresult' in this scope
xpcom/base/CycleCollectedJSRuntime.cpp:1605,7:: error: use of undeclared identifier 'PR_GetEnv'
xpcom/base/CycleCollectedJSRuntime.cpp:1605:7: error: use of undeclared identifier 'PR_GetEnv'
xpcom/base/DeferredFinalize.cpp:12,15:: error: out-of-line definition of 'DeferredFinalize' does not match any declaration in namespace 'mozilla'
xpcom/base/DeferredFinalize.cpp:12:15: error: out-of-line definition of 'DeferredFinalize' does not match any declaration in namespace 'mozilla'
xpcom/base/MemoryTelemetry.cpp:48,27:: error: unused variable 'kTotalMemoryCollectorTimeout' [-Werror,-Wunused-const-variable]
xpcom/base/MemoryTelemetry.cpp:48:27: error: unused variable 'kTotalMemoryCollectorTimeout' [-Werror,-Wunused-const-variable]
xpcom/base/nsErrorService.cpp:42,21:: error: use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension [-Werror,-Wc++20-extensions]
xpcom/base/nsErrorService.cpp:42,21:: error: use of undeclared identifier 'MakeUnique'; did you mean 'mozilla::MakeUnique'?
xpcom/base/nsErrorService.cpp:42:21: error: use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension [-Werror,-Wc++20-extensions]
xpcom/base/nsErrorService.cpp:42:21: error: use of undeclared identifier 'MakeUnique'; did you mean 'mozilla::MakeUnique'?
xpcom/base/nsMacPreferencesReader.mm:20:12: error: implicit instantiation of undefined template 'nsTSubstring<char16_t>'
xpcom/base/nsMacPreferencesReader.mm:24:60: error: use of undeclared identifier 'NSString'
xpcom/base/nsMacPreferencesReader.mm:24:69: error: expected expression
xpcom/base/nsMacPreferencesReader.mm:26:48: error: unknown type name 'NSArray'
xpcom/base/nsMacPreferencesReader.mm:28:30: error: use of undeclared identifier 'NSString'
xpcom/base/nsMacPreferencesReader.mm:29:30: error: no matching function for call to 'MakeStringSpan'
xpcom/base/nsMacPreferencesReader.mm:29:51: error: instance method '-UTF8String' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access]
xpcom/base/nsMacPreferencesReader.mm:30:22: error: instance method '-isKindOfClass:' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access]
xpcom/base/nsMacPreferencesReader.mm:30:37: error: receiver type 'int (*)(int)' is not 'id' or interface pointer, consider casting it to 'id' [-Werror,-Wreceiver-expr]
xpcom/base/nsMacPreferencesReader.mm:30:37: error: use of undeclared identifier 'NSNumber'; did you mean 'isnumber'?
xpcom/base/nsMacPreferencesReader.mm:30:46: error: instance method '-class' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access]
xpcom/base/nsMacPreferencesReader.mm:31:27: error: cannot initialize a parameter of type 'int64_t' (aka 'long long') with an rvalue of type 'id'
xpcom/base/nsMacPreferencesReader.mm:31:33: error: instance method '-longLongValue' not found (return type defaults to 'id') [-Werror,-Wobjc-method-access]
xpcom/base/nsMacPreferencesReader.mm:32:37: error: use of undeclared identifier 'NSArray'
xpcom/base/nsMacPreferencesReader.mm:34:7: error: no matching function for call to 'EvaluateArray'
xpcom/base/nsMacPreferencesReader.mm:36:37: error: use of undeclared identifier 'NSDictionary'
xpcom/base/nsMacPreferencesReader.mm:38:7: error: no matching function for call to 'EvaluateDict'
xpcom/base/nsMacPreferencesReader.mm:44:60: error: use of undeclared identifier 'NSString'
xpcom/base/nsMacPreferencesReader.mm:44:69: error: expected expression
xpcom/base/nsSystemInfo.cpp:415,35:: error: no template named 'NotNull'; did you mean 'NonNull'?
xpcom/base/nsSystemInfo.cpp:419,25:: error: member reference type 'NonNull<IWSCProductList *>' is not a pointer; did you mean to use '.'?
xpcom/base/nsSystemInfo.cpp:419,27:: error: no member named 'get_Count' in 'mozilla::dom::NonNull<IWSCProductList *>'
xpcom/base/nsSystemInfo.cpp:426,19:: error: member reference type 'NonNull<IWSCProductList *>' is not a pointer; did you mean to use '.'?
xpcom/base/nsSystemInfo.cpp:426,21:: error: no member named 'get_Item' in 'mozilla::dom::NonNull<IWSCProductList *>'
xpcom/base/nsSystemInfo.cpp:484,17:: error: use of undeclared identifier 'ArrayLength'; did you mean 'mozilla::ArrayLength'?
xpcom/base/nsSystemInfo.cpp:484,47:: error: use of undeclared identifier 'ArrayLength'; did you mean 'mozilla::ArrayLength'?
xpcom/base/nsSystemInfo.cpp:487,36:: error: use of undeclared identifier 'ArrayLength'; did you mean 'mozilla::ArrayLength'?
xpcom/base/nsSystemInfo.cpp:500,10:: error: no matching function for call to 'EnumWSCProductList'
xpcom/base/nsSystemInfo.cpp:500,46:: error: use of undeclared identifier 'WrapNotNull'; did you mean 'mozilla::WrapNotNull'?
xpcom/base/nsTraceRefcnt.cpp:313,32:: error: use of undeclared identifier 'MakeUnique'
xpcom/base/nsTraceRefcnt.cpp:313:32: error: use of undeclared identifier 'MakeUnique'
xpcom/base/nsTraceRefcnt.cpp:461,19:: error: no matching member function for call to 'WithEntryHandle'
xpcom/base/nsTraceRefcnt.cpp:461:19: error: no matching member function for call to 'WithEntryHandle'
xpcom/base/nsTraceRefcnt.cpp:468,33:: error: use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension [-Werror,-Wc++20-extensions]
xpcom/base/nsTraceRefcnt.cpp:468,33:: error: use of undeclared identifier 'MakeUnique'
xpcom/base/nsTraceRefcnt.cpp:468:33: error: use of undeclared identifier 'MakeUnique'
xpcom/base/nsTraceRefcnt.cpp:736,20:: error: use of undeclared identifier '_write'
Differential Revision: https://phabricator.services.mozilla.com/D127036
2021-10-01 04:49:16 +03:00
|
|
|
Atomic<uint32_t, MemoryOrdering::Relaxed> sNumLowPhysicalMemEvents;
|
|
|
|
|
2011-12-19 20:57:57 +04:00
|
|
|
namespace {
|
2011-12-15 23:48:38 +04:00
|
|
|
|
2018-05-17 15:48:02 +03:00
|
|
|
#if defined(XP_WIN)
|
2011-12-15 23:48:38 +04:00
|
|
|
|
2019-05-26 10:45:56 +03:00
|
|
|
# if (NTDDI_VERSION < NTDDI_WINBLUE) || \
|
|
|
|
(NTDDI_VERSION == NTDDI_WINBLUE && !defined(WINBLUE_KBSPRING14))
|
|
|
|
// Definitions for heap optimization that require the Windows SDK to target the
|
|
|
|
// Windows 8.1 Update
|
|
|
|
static const HEAP_INFORMATION_CLASS HeapOptimizeResources =
|
|
|
|
static_cast<HEAP_INFORMATION_CLASS>(3);
|
|
|
|
|
|
|
|
static const DWORD HEAP_OPTIMIZE_RESOURCES_CURRENT_VERSION = 1;
|
|
|
|
|
|
|
|
typedef struct _HEAP_OPTIMIZE_RESOURCES_INFORMATION {
|
|
|
|
DWORD Version;
|
|
|
|
DWORD Flags;
|
|
|
|
} HEAP_OPTIMIZE_RESOURCES_INFORMATION, *PHEAP_OPTIMIZE_RESOURCES_INFORMATION;
|
|
|
|
# endif
|
|
|
|
|
2021-03-31 18:18:05 +03:00
|
|
|
static int64_t LowMemoryEventsPhysicalDistinguishedAmount() {
|
|
|
|
return sNumLowPhysicalMemEvents;
|
2018-05-16 14:58:10 +03:00
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class LowEventsReporter final : public nsIMemoryReporter {
|
2014-07-15 05:47:01 +04:00
|
|
|
~LowEventsReporter() {}
|
|
|
|
|
2011-12-19 20:57:57 +04:00
|
|
|
public:
|
2013-12-08 10:09:10 +04:00
|
|
|
NS_DECL_ISUPPORTS
|
2011-12-19 20:57:57 +04:00
|
|
|
|
2013-12-08 10:09:10 +04:00
|
|
|
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
2016-08-08 04:04:11 +03:00
|
|
|
nsISupports* aData, bool aAnonymize) override {
|
2018-11-29 00:06:13 +03:00
|
|
|
// clang-format off
|
2016-09-14 14:52:45 +03:00
|
|
|
MOZ_COLLECT_REPORT(
|
2021-03-31 18:18:05 +03:00
|
|
|
"low-memory-events/physical", KIND_OTHER, UNITS_COUNT_CUMULATIVE,
|
|
|
|
LowMemoryEventsPhysicalDistinguishedAmount(),
|
|
|
|
"Number of low-physical-memory events fired since startup. We fire such an "
|
|
|
|
"event when a windows low memory resource notification is signaled. The "
|
|
|
|
"machine will start to page if it runs out of physical memory. This may "
|
|
|
|
"cause it to run slowly, but it shouldn't cause it to crash.");
|
2018-11-29 00:06:13 +03:00
|
|
|
// clang-format on
|
2011-12-19 20:57:57 +04:00
|
|
|
|
2013-12-08 10:09:10 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-01-18 09:43:21 +04:00
|
|
|
};
|
2021-07-07 01:30:57 +03:00
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(LowEventsReporter, nsIMemoryReporter)
|
2011-12-19 20:57:57 +04:00
|
|
|
|
2018-05-17 15:48:02 +03:00
|
|
|
#endif // defined(XP_WIN)
|
2012-11-12 20:41:23 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This runnable is executed in response to a memory-pressure event; we spin
|
|
|
|
* the event-loop when receiving the memory-pressure event in the hope that
|
|
|
|
* other observers will synchronously free some memory that we'll be able to
|
|
|
|
* purge here.
|
|
|
|
*/
|
2020-05-20 23:37:58 +03:00
|
|
|
class nsJemallocFreeDirtyPagesRunnable final : public Runnable {
|
2020-02-12 14:13:33 +03:00
|
|
|
~nsJemallocFreeDirtyPagesRunnable() = default;
|
2014-07-01 02:11:53 +04:00
|
|
|
|
2019-05-26 10:45:56 +03:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
void OptimizeSystemHeap();
|
|
|
|
#endif
|
|
|
|
|
2012-11-12 20:41:23 +04:00
|
|
|
public:
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
|
2020-05-25 10:42:38 +03:00
|
|
|
nsJemallocFreeDirtyPagesRunnable()
|
|
|
|
: Runnable("nsJemallocFreeDirtyPagesRunnable") {}
|
2020-05-20 23:37:58 +03:00
|
|
|
};
|
2012-11-12 20:41:23 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJemallocFreeDirtyPagesRunnable::Run() {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2012-12-07 12:32:24 +04:00
|
|
|
#if defined(MOZ_MEMORY)
|
2012-11-12 20:41:23 +04:00
|
|
|
jemalloc_free_dirty_pages();
|
|
|
|
#endif
|
|
|
|
|
2019-05-26 10:45:56 +03:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
OptimizeSystemHeap();
|
|
|
|
#endif
|
|
|
|
|
2012-11-12 20:41:23 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-26 10:45:56 +03:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
void nsJemallocFreeDirtyPagesRunnable::OptimizeSystemHeap() {
|
2023-07-25 17:41:05 +03:00
|
|
|
HEAP_OPTIMIZE_RESOURCES_INFORMATION heapOptInfo = {
|
|
|
|
HEAP_OPTIMIZE_RESOURCES_CURRENT_VERSION};
|
|
|
|
|
|
|
|
::HeapSetInformation(nullptr, HeapOptimizeResources, &heapOptInfo,
|
|
|
|
sizeof(heapOptInfo));
|
2019-05-26 10:45:56 +03:00
|
|
|
}
|
|
|
|
#endif // defined(XP_WIN)
|
|
|
|
|
2012-11-12 20:41:23 +04:00
|
|
|
/**
|
|
|
|
* The memory pressure watcher is used for listening to memory-pressure events
|
|
|
|
* and reacting upon them. We use one instance per process currently only for
|
|
|
|
* cleaning up dirty unused pages held by jemalloc.
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsMemoryPressureWatcher final : public nsIObserver {
|
2020-02-12 14:13:33 +03:00
|
|
|
~nsMemoryPressureWatcher() = default;
|
2014-07-01 02:11:53 +04:00
|
|
|
|
2012-11-12 20:41:23 +04:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
void Init();
|
|
|
|
};
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsMemoryPressureWatcher, nsIObserver)
|
2012-11-12 20:41:23 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize and subscribe to the memory-pressure events. We subscribe to the
|
|
|
|
* observer service in this method and not in the constructor because we need
|
|
|
|
* to hold a strong reference to 'this' before calling the observer service.
|
|
|
|
*/
|
|
|
|
void nsMemoryPressureWatcher::Init() {
|
|
|
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
|
|
|
|
|
|
|
if (os) {
|
|
|
|
os->AddObserver(this, "memory-pressure", /* ownsWeak */ false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reacts to all types of memory-pressure events, launches a runnable to
|
|
|
|
* free dirty pages held by jemalloc.
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
2014-05-13 21:41:38 +04:00
|
|
|
nsMemoryPressureWatcher::Observe(nsISupports* aSubject, const char* aTopic,
|
|
|
|
const char16_t* aData) {
|
|
|
|
MOZ_ASSERT(!strcmp(aTopic, "memory-pressure"), "Unknown topic");
|
2012-11-12 20:41:23 +04:00
|
|
|
|
2017-11-07 11:34:18 +03:00
|
|
|
nsCOMPtr<nsIRunnable> runnable = new nsJemallocFreeDirtyPagesRunnable();
|
2012-11-12 20:41:23 +04:00
|
|
|
|
2017-11-07 11:34:18 +03:00
|
|
|
NS_DispatchToMainThread(runnable);
|
2012-11-12 20:41:23 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace
|
2011-12-19 20:57:57 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace AvailableMemoryTracker {
|
|
|
|
|
2018-07-04 22:06:07 +03:00
|
|
|
void Init() {
|
|
|
|
// The watchers are held alive by the observer service.
|
|
|
|
RefPtr<nsMemoryPressureWatcher> watcher = new nsMemoryPressureWatcher();
|
|
|
|
watcher->Init();
|
2012-04-09 21:53:08 +04:00
|
|
|
|
2018-07-04 22:06:07 +03:00
|
|
|
#if defined(XP_WIN)
|
2021-03-31 18:18:05 +03:00
|
|
|
RegisterLowMemoryEventsPhysicalDistinguishedAmount(
|
|
|
|
LowMemoryEventsPhysicalDistinguishedAmount);
|
2018-07-04 22:06:07 +03:00
|
|
|
#endif // defined(XP_WIN)
|
2011-12-15 23:48:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace AvailableMemoryTracker
|
|
|
|
} // namespace mozilla
|