src/share/vm/services/memTracker.cpp

changeset 4890
4c8bb5e4f68f
parent 4810
06db4c0afbf3
child 4927
35f8765422b9
     1.1 --- a/src/share/vm/services/memTracker.cpp	Thu Apr 04 10:01:26 2013 -0700
     1.2 +++ b/src/share/vm/services/memTracker.cpp	Fri Apr 05 12:19:19 2013 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -127,12 +127,15 @@
    1.11    assert(_state == NMT_bootstrapping_multi_thread, "wrong state");
    1.12  
    1.13    _snapshot = new (std::nothrow)MemSnapshot();
    1.14 -  if (_snapshot != NULL && !_snapshot->out_of_memory()) {
    1.15 -    if (start_worker()) {
    1.16 +  if (_snapshot != NULL) {
    1.17 +    if (!_snapshot->out_of_memory() && start_worker()) {
    1.18        _state = NMT_started;
    1.19        NMT_track_callsite = (_tracking_level == NMT_detail && can_walk_stack());
    1.20        return;
    1.21      }
    1.22 +
    1.23 +    delete _snapshot;
    1.24 +    _snapshot = NULL;
    1.25    }
    1.26  
    1.27    // fail to start native memory tracking, shut it down
    1.28 @@ -544,7 +547,10 @@
    1.29    assert(_worker_thread == NULL, "Just Check");
    1.30    _worker_thread = new (std::nothrow) MemTrackWorker();
    1.31    if (_worker_thread == NULL || _worker_thread->has_error()) {
    1.32 -    shutdown(NMT_initialization);
    1.33 +    if (_worker_thread != NULL) {
    1.34 +      delete _worker_thread;
    1.35 +      _worker_thread = NULL;
    1.36 +    }
    1.37      return false;
    1.38    }
    1.39    _worker_thread->start();

mercurial