diff --git a/src/share/vm/runtime/arguments.cpp b/src/share/vm/runtime/arguments.cpp index b68048220d1fd066452da014bd9bb70b75a92a55..0d632a99c1a6f1a9ff74a1deb36f8a21ab2c261c 100644 --- a/src/share/vm/runtime/arguments.cpp +++ b/src/share/vm/runtime/arguments.cpp @@ -1978,6 +1978,12 @@ bool Arguments::check_vm_args_consistency() { status = status && verify_min_value(ClassMetaspaceSize, 1*M, "ClassMetaspaceSize"); + // check native memory tracking flags + if (PrintNMTStatistics && MemTracker::tracking_level() == MemTracker::NMT_off) { + warning("PrintNMTStatistics is disabled, because native memory tracking is not enabled"); + PrintNMTStatistics = false; + } + return status; } diff --git a/src/share/vm/runtime/globals.hpp b/src/share/vm/runtime/globals.hpp index e4a97abbd5f22611392c37c7f2c08dbe3493c6d1..8ecd8d304bca9f73eb309f97c1fbc348bf03c20d 100644 --- a/src/share/vm/runtime/globals.hpp +++ b/src/share/vm/runtime/globals.hpp @@ -863,6 +863,9 @@ class CommandLineFlags { product(ccstr, NativeMemoryTracking, "off", \ "Native memory tracking options") \ \ + diagnostic(bool, PrintNMTStatistics, false, \ + "Print native memory tracking summary data if it is on") \ + \ diagnostic(bool, LogCompilation, false, \ "Log compilation activity in detail to hotspot.log or LogFile") \ \ diff --git a/src/share/vm/runtime/java.cpp b/src/share/vm/runtime/java.cpp index 8b3aab39a65fe1e3a133975725ce7f70dbade39a..d40794529d64458082f6bb4d773c651efd246a52 100644 --- a/src/share/vm/runtime/java.cpp +++ b/src/share/vm/runtime/java.cpp @@ -56,6 +56,8 @@ #include "runtime/task.hpp" #include "runtime/timer.hpp" #include "runtime/vm_operations.hpp" +#include "services/memReporter.hpp" +#include "services/memTracker.hpp" #include "trace/tracing.hpp" #include "trace/traceEventTypes.hpp" #include "utilities/dtrace.hpp" @@ -359,6 +361,15 @@ void print_statistics() { } #endif // COMPILER2 #endif // ENABLE_ZAP_DEAD_LOCALS + // Native memory tracking data + if (PrintNMTStatistics) { + if (MemTracker::is_on()) { + BaselineTTYOutputer outputer(tty); + MemTracker::print_memory_usage(outputer, K, false); + } else { + tty->print_cr(MemTracker::reason()); + } + } } #else // PRODUCT MODE STATISTICS @@ -376,6 +387,16 @@ void print_statistics() { if (PrintBiasedLockingStatistics) { BiasedLocking::print_counters(); } + + // Native memory tracking data + if (PrintNMTStatistics) { + if (MemTracker::is_on()) { + BaselineTTYOutputer outputer(tty); + MemTracker::print_memory_usage(outputer, K, false); + } else { + tty->print_cr(MemTracker::reason()); + } + } } #endif diff --git a/src/share/vm/services/memTracker.hpp b/src/share/vm/services/memTracker.hpp index eea28c169d06d2132b63f416dd8bb72e2ff5e5a9..7c26f31a8f7539b4c4bde733b77e4387b30955d3 100644 --- a/src/share/vm/services/memTracker.hpp +++ b/src/share/vm/services/memTracker.hpp @@ -85,7 +85,7 @@ class MemTracker : AllStatic { NMT_shutdown // shutdown }; - + public: // native memory tracking level enum NMTLevel { NMT_off, // native memory tracking is off @@ -93,7 +93,6 @@ class MemTracker : AllStatic { NMT_detail // track callsite also }; - public: enum ShutdownReason { NMT_shutdown_none, // no shutdown requested NMT_shutdown_user, // user requested shutdown @@ -117,6 +116,10 @@ class MemTracker : AllStatic { _state >= NMT_bootstrapping_single_thread); } + static inline enum NMTLevel tracking_level() { + return _tracking_level; + } + // user readable reason for shutting down NMT static const char* reason() { switch(_reason) {