8371778: Make MallocMemorySummary::_snapshot a DeferredStatic

Reviewed-by: phubner, azafari
This commit is contained in:
Johan Sjölen 2025-11-18 13:05:57 +00:00
parent f946449997
commit 36b66e13c8
2 changed files with 5 additions and 4 deletions

View File

@ -45,7 +45,7 @@
#include "utilities/ostream.hpp"
#include "utilities/vmError.hpp"
MallocMemorySnapshot MallocMemorySummary::_snapshot;
DeferredStatic<MallocMemorySnapshot> MallocMemorySummary::_snapshot;
void MemoryCounter::update_peak(size_t size, size_t cnt) {
size_t peak_sz = peak_size();
@ -101,7 +101,7 @@ void MallocMemorySnapshot::make_adjustment() {
}
void MallocMemorySummary::initialize() {
// Uses placement new operator to initialize static area.
_snapshot.initialize();
MallocLimitHandler::initialize(MallocLimit);
}

View File

@ -30,6 +30,7 @@
#include "nmt/memTag.hpp"
#include "nmt/nmtCommon.hpp"
#include "runtime/atomicAccess.hpp"
#include "utilities/deferredStatic.hpp"
#include "utilities/nativeCallStack.hpp"
class outputStream;
@ -204,7 +205,7 @@ class MallocMemorySnapshot {
class MallocMemorySummary : AllStatic {
private:
// Reserve memory for placement of MallocMemorySnapshot object
static MallocMemorySnapshot _snapshot;
static DeferredStatic<MallocMemorySnapshot> _snapshot;
static bool _have_limits;
// Called when a total limit break was detected.
@ -251,7 +252,7 @@ class MallocMemorySummary : AllStatic {
}
static MallocMemorySnapshot* as_snapshot() {
return &_snapshot;
return _snapshot.get();
}
// MallocLimit: returns true if allocating s bytes on f would trigger