Merge
authorzgu
Thu, 19 Jul 2012 09:10:12 -0400
changeset 13302 2c447ccac6e6
parent 13300 38485c548c9f (current diff)
parent 13301 f6dd749390dd (diff)
child 13304 f97566d01de4
Merge
hotspot/src/share/vm/services/memTracker.cpp
hotspot/src/share/vm/services/memTracker.hpp
--- a/hotspot/src/share/vm/services/memSnapshot.cpp	Thu Jul 19 09:05:42 2012 -0400
+++ b/hotspot/src/share/vm/services/memSnapshot.cpp	Thu Jul 19 09:10:12 2012 -0400
@@ -173,7 +173,7 @@
     _staging_area = new (std::nothrow)MemPointerArrayImpl<SeqMemPointerRecord>();
   }
 
-  _lock = new (std::nothrow) Mutex(Monitor::native, "memSnapshotLock");
+  _lock = new (std::nothrow) Mutex(Monitor::max_nonleaf - 1, "memSnapshotLock");
   NOT_PRODUCT(_untracked_count = 0;)
 }
 
--- a/hotspot/src/share/vm/services/memTracker.cpp	Thu Jul 19 09:05:42 2012 -0400
+++ b/hotspot/src/share/vm/services/memTracker.cpp	Thu Jul 19 09:10:12 2012 -0400
@@ -54,7 +54,7 @@
 MemRecorder*                    MemTracker::_global_recorder = NULL;
 MemSnapshot*                    MemTracker::_snapshot = NULL;
 MemBaseline                     MemTracker::_baseline;
-Mutex                           MemTracker::_query_lock(Monitor::native, "NMT_queryLock");
+Mutex*                          MemTracker::_query_lock = NULL;
 volatile MemRecorder*           MemTracker::_merge_pending_queue = NULL;
 volatile MemRecorder*           MemTracker::_pooled_recorders = NULL;
 MemTrackWorker*                 MemTracker::_worker_thread = NULL;
@@ -89,6 +89,12 @@
       return;
     }
 
+    _query_lock = new (std::nothrow) Mutex(Monitor::max_nonleaf, "NMT_queryLock");
+    if (_query_lock == NULL) {
+      shutdown(NMT_out_of_memory);
+      return;
+    }
+
     debug_only(_main_thread_tid = os::current_thread_id();)
     _state = NMT_bootstrapping_single_thread;
     NMT_track_callsite = (_tracking_level == NMT_detail && can_walk_stack());
@@ -164,7 +170,7 @@
   {
     // shared baseline and snapshot are the only objects needed to
     // create query results
-    MutexLockerEx locker(&_query_lock, true);
+    MutexLockerEx locker(_query_lock, true);
     // cleanup baseline data and snapshot
     _baseline.clear();
     delete _snapshot;
@@ -536,7 +542,7 @@
 
 // baseline current memory snapshot
 bool MemTracker::baseline() {
-  MutexLockerEx lock(&_query_lock, true);
+  MutexLockerEx lock(_query_lock, true);
   MemSnapshot* snapshot = get_snapshot();
   if (snapshot != NULL) {
     return _baseline.baseline(*snapshot, false);
@@ -547,7 +553,7 @@
 // print memory usage from current snapshot
 bool MemTracker::print_memory_usage(BaselineOutputer& out, size_t unit, bool summary_only) {
   MemBaseline  baseline;
-  MutexLockerEx lock(&_query_lock, true);
+  MutexLockerEx lock(_query_lock, true);
   MemSnapshot* snapshot = get_snapshot();
   if (snapshot != NULL && baseline.baseline(*snapshot, summary_only)) {
     BaselineReporter reporter(out, unit);
@@ -559,7 +565,7 @@
 
 // compare memory usage between current snapshot and baseline
 bool MemTracker::compare_memory_usage(BaselineOutputer& out, size_t unit, bool summary_only) {
-  MutexLockerEx lock(&_query_lock, true);
+  MutexLockerEx lock(_query_lock, true);
   if (_baseline.baselined()) {
     MemBaseline baseline;
     MemSnapshot* snapshot = get_snapshot();
--- a/hotspot/src/share/vm/services/memTracker.hpp	Thu Jul 19 09:05:42 2012 -0400
+++ b/hotspot/src/share/vm/services/memTracker.hpp	Thu Jul 19 09:10:12 2012 -0400
@@ -126,6 +126,8 @@
         return "Native memory tracking has been shutdown by user";
       case NMT_normal:
         return "Native memory tracking has been shutdown due to process exiting";
+      case NMT_out_of_memory:
+        return "Native memory tracking has been shutdown due to out of native memory";
       case NMT_initialization:
         return "Native memory tracking failed to initialize";
       case NMT_error_reporting:
@@ -336,7 +338,7 @@
   static MemBaseline      _baseline;
 
   // query lock
-  static Mutex            _query_lock;
+  static Mutex*           _query_lock;
 
   // a thread can start to allocate memory before it is attached
   // to VM 'Thread', those memory activities are recorded here.