8315462: [REDO] runtime/NMT/SummarySanityCheck.java failed with "Total committed (MMMMMM) did not match the summarized committed (NNNNNN)"
Reviewed-by: gziemski, stuefe
This commit is contained in:
parent
a5122d7f6c
commit
66aeb89469
src/hotspot/share/nmt
@ -59,6 +59,23 @@ void MemoryCounter::update_peak(size_t size, size_t cnt) {
|
||||
}
|
||||
}
|
||||
|
||||
void MallocMemorySnapshot::copy_to(MallocMemorySnapshot* s) {
|
||||
// Use ThreadCritical to make sure that mtChunks don't get deallocated while the
|
||||
// copy is going on, because their size is adjusted using this
|
||||
// buffer in make_adjustment().
|
||||
ThreadCritical tc;
|
||||
s->_all_mallocs = _all_mallocs;
|
||||
size_t total_size = 0;
|
||||
size_t total_count = 0;
|
||||
for (int index = 0; index < mt_number_of_types; index ++) {
|
||||
s->_malloc[index] = _malloc[index];
|
||||
total_size += s->_malloc[index].malloc_size();
|
||||
total_count += s->_malloc[index].malloc_count();
|
||||
}
|
||||
// malloc counters may be updated concurrently
|
||||
s->_all_mallocs.set_size_and_count(total_size, total_count);
|
||||
}
|
||||
|
||||
// Total malloc'd memory used by arenas
|
||||
size_t MallocMemorySnapshot::total_arena() const {
|
||||
size_t amount = 0;
|
||||
|
@ -55,6 +55,12 @@ class MemoryCounter {
|
||||
public:
|
||||
MemoryCounter() : _count(0), _size(0), _peak_count(0), _peak_size(0) {}
|
||||
|
||||
inline void set_size_and_count(size_t size, size_t count) {
|
||||
_size = size;
|
||||
_count = count;
|
||||
update_peak(size, count);
|
||||
}
|
||||
|
||||
inline void allocate(size_t sz) {
|
||||
size_t cnt = Atomic::add(&_count, size_t(1), memory_order_relaxed);
|
||||
if (sz > 0) {
|
||||
@ -176,16 +182,7 @@ class MallocMemorySnapshot {
|
||||
// Total malloc'd memory used by arenas
|
||||
size_t total_arena() const;
|
||||
|
||||
void copy_to(MallocMemorySnapshot* s) {
|
||||
// Need to make sure that mtChunks don't get deallocated while the
|
||||
// copy is going on, because their size is adjusted using this
|
||||
// buffer in make_adjustment().
|
||||
ThreadCritical tc;
|
||||
s->_all_mallocs = _all_mallocs;
|
||||
for (int index = 0; index < mt_number_of_types; index ++) {
|
||||
s->_malloc[index] = _malloc[index];
|
||||
}
|
||||
}
|
||||
void copy_to(MallocMemorySnapshot* s);
|
||||
|
||||
// Make adjustment by subtracting chunks used by arenas
|
||||
// from total chunks to get total free chunk size
|
||||
|
Loading…
x
Reference in New Issue
Block a user