changeset 4333:8b70e9942bd3

7188594: Print statistic collected by NMT with VM flag Summary: Print out statistics of collected NMT data if it is on at VM exits Reviewed-by: kvn, coleenp, twisti
author zgu
date Mon, 17 Sep 2012 16:37:26 -0400
parents aa65674c0e22
children 490ddaa553ad
files src/share/vm/runtime/arguments.cpp src/share/vm/runtime/globals.hpp src/share/vm/runtime/java.cpp src/share/vm/services/memTracker.hpp
diffstat 4 files changed, 35 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/runtime/arguments.cpp	Mon Sep 17 10:20:04 2012 -0400
+++ b/src/share/vm/runtime/arguments.cpp	Mon Sep 17 16:37:26 2012 -0400
@@ -1959,6 +1959,12 @@
   }
 #endif // SPARC
 
+  // 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;
 }
 
--- a/src/share/vm/runtime/globals.hpp	Mon Sep 17 10:20:04 2012 -0400
+++ b/src/share/vm/runtime/globals.hpp	Mon Sep 17 16:37:26 2012 -0400
@@ -860,6 +860,9 @@
   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")   \
                                                                             \
--- a/src/share/vm/runtime/java.cpp	Mon Sep 17 10:20:04 2012 -0400
+++ b/src/share/vm/runtime/java.cpp	Mon Sep 17 16:37:26 2012 -0400
@@ -57,6 +57,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"
@@ -356,6 +358,15 @@
   }
 #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
@@ -373,6 +384,16 @@
   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
--- a/src/share/vm/services/memTracker.hpp	Mon Sep 17 10:20:04 2012 -0400
+++ b/src/share/vm/services/memTracker.hpp	Mon Sep 17 16:37:26 2012 -0400
@@ -85,7 +85,7 @@
     NMT_shutdown                         // shutdown
   };
 
-
+ public:
   // native memory tracking level
   enum NMTLevel {
     NMT_off,              // native memory tracking is off
@@ -93,7 +93,6 @@
     NMT_detail            // track callsite also
   };
 
- public:
    enum ShutdownReason {
      NMT_shutdown_none,     // no shutdown requested
      NMT_shutdown_user,     // user requested shutdown
@@ -117,6 +116,10 @@
       _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) {