Skip to content
Permalink
Browse files
8269571: NMT should print total malloc bytes and invocation count
Reviewed-by: zgu, xliu
  • Loading branch information
tstuefe committed Jun 30, 2021
1 parent b969136 commit 3ad20fcdfa35796c190ccbaf26872b0fe30d8c76
Showing with 25 additions and 5 deletions.
  1. +9 −0 src/hotspot/share/services/mallocTracker.cpp
  2. +2 −0 src/hotspot/share/services/mallocTracker.hpp
  3. +14 −5 src/hotspot/share/services/memReporter.cpp
@@ -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;
@@ -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
@@ -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 ++) {

3 comments on commit 3ad20fc

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot replied Jun 30, 2021

@tstuefe

This comment has been minimized.

Copy link
Member Author

@tstuefe tstuefe replied Jun 30, 2021

/backport jdk11u-dev

@openjdk

This comment has been minimized.

Copy link

@openjdk openjdk bot replied Jun 30, 2021

@tstuefe could not automatically backport 3ad20fcd to openjdk/jdk11u-dev due to conflicts in the following files:

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

To manually resolve these conflicts run the following commands in your personal fork of openjdk/jdk11u-dev:

$ git checkout -b tstuefe-backport-3ad20fcd
$ git fetch --no-tags https://git.openjdk.java.net/jdk 3ad20fcdfa35796c190ccbaf26872b0fe30d8c76
$ git cherry-pick --no-commit 3ad20fcdfa35796c190ccbaf26872b0fe30d8c76
$ # Resolve conflicts
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 3ad20fcdfa35796c190ccbaf26872b0fe30d8c76'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk11u-dev with the title Backport 3ad20fcdfa35796c190ccbaf26872b0fe30d8c76.

Please sign in to comment.