--- a/hotspot/src/share/vm/runtime/arguments.cpp Tue Sep 18 10:10:43 2012 -0700
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Wed Sep 19 08:41:30 2012 -0700
@@ -1978,6 +1978,12 @@
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;
}
--- a/hotspot/src/share/vm/runtime/globals.hpp Tue Sep 18 10:10:43 2012 -0700
+++ b/hotspot/src/share/vm/runtime/globals.hpp Wed Sep 19 08:41:30 2012 -0700
@@ -863,6 +863,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/hotspot/src/share/vm/runtime/java.cpp Tue Sep 18 10:10:43 2012 -0700
+++ b/hotspot/src/share/vm/runtime/java.cpp Wed Sep 19 08:41:30 2012 -0700
@@ -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 @@
}
#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 @@
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/hotspot/src/share/vm/services/memTracker.hpp Tue Sep 18 10:10:43 2012 -0700
+++ b/hotspot/src/share/vm/services/memTracker.hpp Wed Sep 19 08:41:30 2012 -0700
@@ -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) {