8269571: NMT should print total malloc bytes and invocation count

Reviewed-by: zgu, xliu
This commit is contained in:
Thomas Stuefe 2021-06-30 04:38:33 +00:00
parent b969136b9f
commit 3ad20fcdfa
3 changed files with 25 additions and 5 deletions

View file

@ -60,6 +60,15 @@ size_t MemoryCounter::peak_size() const {
}
#endif
// Total malloc invocation count
size_t MallocMemorySnapshot::total_count() const {
size_t amount = 0;
for (int index = 0; index < mt_number_of_types; index ++) {
amount += _malloc[index].malloc_count();
}
return amount;
}
// Total malloc'd memory amount
size_t MallocMemorySnapshot::total() const {
size_t amount = 0;

View file

@ -153,6 +153,8 @@ class MallocMemorySnapshot : public ResourceObj {
return &_tracking_header;
}
// Total malloc invocation count
size_t total_count() const;
// Total malloc'd memory amount
size_t total() const;
// Total malloc'd memory used by arenas

View file

@ -98,10 +98,12 @@ void MemReporterBase::print_virtual_memory_region(const char* type, address base
void MemSummaryReporter::report() {
outputStream* out = output();
size_t total_reserved_amount = _malloc_snapshot->total() +
_vm_snapshot->total_reserved();
size_t total_committed_amount = _malloc_snapshot->total() +
_vm_snapshot->total_committed();
const size_t total_malloced_bytes = _malloc_snapshot->total();
const size_t total_mmap_reserved_bytes = _vm_snapshot->total_reserved();
const size_t total_mmap_committed_bytes = _vm_snapshot->total_committed();
size_t total_reserved_amount = total_malloced_bytes + total_mmap_reserved_bytes;
size_t total_committed_amount = total_malloced_bytes + total_mmap_committed_bytes;
// Overall total
out->print_cr("\nNative Memory Tracking:\n");
@ -113,7 +115,14 @@ void MemSummaryReporter::report() {
out->print("Total: ");
print_total(total_reserved_amount, total_committed_amount);
out->print("\n");
out->cr();
out->print_cr(" malloc: " SIZE_FORMAT "%s #" SIZE_FORMAT,
amount_in_current_scale(total_malloced_bytes), current_scale(),
_malloc_snapshot->total_count());
out->print(" mmap: ");
print_total(total_mmap_reserved_bytes, total_mmap_committed_bytes);
out->cr();
out->cr();
// Summary by memory type
for (int index = 0; index < mt_number_of_types; index ++) {