@@ -46,25 +46,20 @@ class MemoryCounter {
46
46
volatile size_t _count;
47
47
volatile size_t _size;
48
48
49
- #ifdef ASSERT
50
49
// Peak size and count. Note: Peak count is the count at the point
51
50
// peak size was reached, not the absolute highest peak count.
52
51
volatile size_t _peak_count;
53
52
volatile size_t _peak_size;
54
53
void update_peak (size_t size, size_t cnt);
55
- #endif // ASSERT
56
54
57
55
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 ) {}
62
57
63
58
inline void allocate (size_t sz) {
64
59
size_t cnt = Atomic::add (&_count, size_t (1 ), memory_order_relaxed);
65
60
if (sz > 0 ) {
66
61
size_t sum = Atomic::add (&_size, sz, memory_order_relaxed);
67
- DEBUG_ONLY ( update_peak (sum, cnt);)
62
+ update_peak (sum, cnt);
68
63
}
69
64
}
70
65
@@ -81,19 +76,19 @@ class MemoryCounter {
81
76
if (sz != 0 ) {
82
77
assert (sz >= 0 || size () >= size_t (-sz), " Must be" );
83
78
size_t sum = Atomic::add (&_size, size_t (sz), memory_order_relaxed);
84
- DEBUG_ONLY ( update_peak (sum, _count);)
79
+ update_peak (sum, _count);
85
80
}
86
81
}
87
82
88
83
inline size_t count () const { return Atomic::load (&_count); }
89
84
inline size_t size () const { return Atomic::load (&_size); }
90
85
91
86
inline size_t peak_count () const {
92
- return DEBUG_ONLY ( Atomic::load (&_peak_count)) NOT_DEBUG ( 0 );
87
+ return Atomic::load (&_peak_count);
93
88
}
94
89
95
90
inline size_t peak_size () const {
96
- return DEBUG_ONLY ( Atomic::load (&_peak_size)) NOT_DEBUG ( 0 );
91
+ return Atomic::load (&_peak_size);
97
92
}
98
93
};
99
94
0 commit comments