8338583: NMT: Malloc overhead is calculated incorrectly

Reviewed-by: azafari, yan, gziemski
This commit is contained in:
Leonov Kirill 2024-09-25 13:18:25 +00:00
parent 083b980831
commit fb70325877
3 changed files with 4 additions and 3 deletions

@ -127,6 +127,7 @@ public:
inline MallocHeader(size_t size, MemTag mem_tag, uint32_t mst_marker);
inline static size_t malloc_overhead() { return sizeof(MallocHeader) + sizeof(uint16_t); }
inline size_t size() const { return _size; }
inline MemTag mem_tag() const { return _mem_tag; }
inline uint32_t mst_marker() const { return _mst_marker; }

@ -166,7 +166,7 @@ class MallocMemorySnapshot {
}
inline size_t malloc_overhead() const {
return _all_mallocs.count() * sizeof(MallocHeader);
return _all_mallocs.count() * MallocHeader::malloc_overhead();
}
// Total malloc invocation count
@ -269,7 +269,7 @@ class MallocTracker : AllStatic {
// The overhead that is incurred by switching on NMT (we need, per malloc allocation,
// space for header and 16-bit footer)
static const size_t overhead_per_malloc = sizeof(MallocHeader) + sizeof(uint16_t);
static inline size_t overhead_per_malloc() { return MallocHeader::malloc_overhead(); }
// Parameter name convention:
// memblock : the beginning address for user data

@ -72,7 +72,7 @@ class MemTracker : AllStatic {
// Per-malloc overhead incurred by NMT, depending on the current NMT level
static size_t overhead_per_malloc() {
return enabled() ? MallocTracker::overhead_per_malloc : 0;
return enabled() ? MallocTracker::overhead_per_malloc() : 0;
}
static inline void* record_malloc(void* mem_base, size_t size, MemTag mem_tag,