Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8269571: NMT should print total malloc bytes and invocation count #821

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/hotspot/share/services/mallocTracker.cpp
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/services/mallocTracker.hpp
Expand Up @@ -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
Expand Down
19 changes: 14 additions & 5 deletions src/hotspot/share/services/memReporter.cpp
Expand Up @@ -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");
Expand All @@ -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 ++) {
Expand Down