Skip to content

Commit 32ccf01

Browse files
committedOct 12, 2023
8317772: NMT: Make peak values available in release builds
Reviewed-by: jsjolen, zgu
1 parent 4c79e7d commit 32ccf01

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed
 

‎src/hotspot/share/services/mallocTracker.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545

4646
size_t MallocMemorySummary::_snapshot[CALC_OBJ_SIZE_IN_TYPE(MallocMemorySnapshot, size_t)];
4747

48-
#ifdef ASSERT
4948
void MemoryCounter::update_peak(size_t size, size_t cnt) {
5049
size_t peak_sz = peak_size();
5150
while (peak_sz < size) {
@@ -59,7 +58,6 @@ void MemoryCounter::update_peak(size_t size, size_t cnt) {
5958
}
6059
}
6160
}
62-
#endif // ASSERT
6361

6462
// Total malloc'd memory used by arenas
6563
size_t MallocMemorySnapshot::total_arena() const {

‎src/hotspot/share/services/mallocTracker.hpp

+5-10
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,20 @@ class MemoryCounter {
4646
volatile size_t _count;
4747
volatile size_t _size;
4848

49-
#ifdef ASSERT
5049
// Peak size and count. Note: Peak count is the count at the point
5150
// peak size was reached, not the absolute highest peak count.
5251
volatile size_t _peak_count;
5352
volatile size_t _peak_size;
5453
void update_peak(size_t size, size_t cnt);
55-
#endif // ASSERT
5654

5755
public:
58-
MemoryCounter() : _count(0), _size(0) {
59-
DEBUG_ONLY(_peak_count = 0;)
60-
DEBUG_ONLY(_peak_size = 0;)
61-
}
56+
MemoryCounter() : _count(0), _size(0), _peak_count(0), _peak_size(0) {}
6257

6358
inline void allocate(size_t sz) {
6459
size_t cnt = Atomic::add(&_count, size_t(1), memory_order_relaxed);
6560
if (sz > 0) {
6661
size_t sum = Atomic::add(&_size, sz, memory_order_relaxed);
67-
DEBUG_ONLY(update_peak(sum, cnt);)
62+
update_peak(sum, cnt);
6863
}
6964
}
7065

@@ -81,19 +76,19 @@ class MemoryCounter {
8176
if (sz != 0) {
8277
assert(sz >= 0 || size() >= size_t(-sz), "Must be");
8378
size_t sum = Atomic::add(&_size, size_t(sz), memory_order_relaxed);
84-
DEBUG_ONLY(update_peak(sum, _count);)
79+
update_peak(sum, _count);
8580
}
8681
}
8782

8883
inline size_t count() const { return Atomic::load(&_count); }
8984
inline size_t size() const { return Atomic::load(&_size); }
9085

9186
inline size_t peak_count() const {
92-
return DEBUG_ONLY(Atomic::load(&_peak_count)) NOT_DEBUG(0);
87+
return Atomic::load(&_peak_count);
9388
}
9489

9590
inline size_t peak_size() const {
96-
return DEBUG_ONLY(Atomic::load(&_peak_size)) NOT_DEBUG(0);
91+
return Atomic::load(&_peak_size);
9792
}
9893
};
9994

‎src/hotspot/share/services/memReporter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ void MemSummaryReporter::report_summary_of_type(MEMFLAGS flag,
246246

247247
// report malloc'd memory
248248
if (amount_in_current_scale(malloc_memory->malloc_size()) > 0
249-
DEBUG_ONLY(|| amount_in_current_scale(malloc_memory->malloc_peak_size()) > 0)) {
249+
|| amount_in_current_scale(malloc_memory->malloc_peak_size()) > 0) {
250250
print_malloc_line(malloc_memory->malloc_counter());
251251
}
252252

0 commit comments

Comments
 (0)
Please sign in to comment.