src/share/vm/services/memTracker.cpp

changeset 4927
35f8765422b9
parent 4890
4c8bb5e4f68f
child 4980
fbca7eaeac2e
     1.1 --- a/src/share/vm/services/memTracker.cpp	Tue Apr 09 08:52:32 2013 -0700
     1.2 +++ b/src/share/vm/services/memTracker.cpp	Wed Apr 10 08:55:50 2013 -0400
     1.3 @@ -53,12 +53,12 @@
     1.4  }
     1.5  
     1.6  
     1.7 -MemRecorder*                    MemTracker::_global_recorder = NULL;
     1.8 +MemRecorder* volatile           MemTracker::_global_recorder = NULL;
     1.9  MemSnapshot*                    MemTracker::_snapshot = NULL;
    1.10  MemBaseline                     MemTracker::_baseline;
    1.11  Mutex*                          MemTracker::_query_lock = NULL;
    1.12 -volatile MemRecorder*           MemTracker::_merge_pending_queue = NULL;
    1.13 -volatile MemRecorder*           MemTracker::_pooled_recorders = NULL;
    1.14 +MemRecorder* volatile           MemTracker::_merge_pending_queue = NULL;
    1.15 +MemRecorder* volatile           MemTracker::_pooled_recorders = NULL;
    1.16  MemTrackWorker*                 MemTracker::_worker_thread = NULL;
    1.17  int                             MemTracker::_sync_point_skip_count = 0;
    1.18  MemTracker::NMTLevel            MemTracker::_tracking_level = MemTracker::NMT_off;
    1.19 @@ -128,7 +128,7 @@
    1.20  
    1.21    _snapshot = new (std::nothrow)MemSnapshot();
    1.22    if (_snapshot != NULL) {
    1.23 -    if (!_snapshot->out_of_memory() && start_worker()) {
    1.24 +    if (!_snapshot->out_of_memory() && start_worker(_snapshot)) {
    1.25        _state = NMT_started;
    1.26        NMT_track_callsite = (_tracking_level == NMT_detail && can_walk_stack());
    1.27        return;
    1.28 @@ -209,7 +209,7 @@
    1.29  // delete all pooled recorders
    1.30  void MemTracker::delete_all_pooled_recorders() {
    1.31    // free all pooled recorders
    1.32 -  volatile MemRecorder* cur_head = _pooled_recorders;
    1.33 +  MemRecorder* volatile cur_head = _pooled_recorders;
    1.34    if (cur_head != NULL) {
    1.35      MemRecorder* null_ptr = NULL;
    1.36      while (cur_head != NULL && (void*)cur_head != Atomic::cmpxchg_ptr((void*)null_ptr,
    1.37 @@ -543,14 +543,14 @@
    1.38  /*
    1.39   * Start worker thread.
    1.40   */
    1.41 -bool MemTracker::start_worker() {
    1.42 -  assert(_worker_thread == NULL, "Just Check");
    1.43 -  _worker_thread = new (std::nothrow) MemTrackWorker();
    1.44 -  if (_worker_thread == NULL || _worker_thread->has_error()) {
    1.45 -    if (_worker_thread != NULL) {
    1.46 -      delete _worker_thread;
    1.47 -      _worker_thread = NULL;
    1.48 -    }
    1.49 +bool MemTracker::start_worker(MemSnapshot* snapshot) {
    1.50 +  assert(_worker_thread == NULL && _snapshot != NULL, "Just Check");
    1.51 +  _worker_thread = new (std::nothrow) MemTrackWorker(snapshot);
    1.52 +  if (_worker_thread == NULL) {
    1.53 +    return false;
    1.54 +  } else if (_worker_thread->has_error()) {
    1.55 +    delete _worker_thread;
    1.56 +    _worker_thread = NULL;
    1.57      return false;
    1.58    }
    1.59    _worker_thread->start();

mercurial