hotspot/src/share/vm/services/nmtDCmd.cpp
author drchase
Fri, 09 May 2014 16:50:54 -0400
changeset 24424 2658d7834c6e
parent 17296 68557efd8583
child 25946 1572c9f03fb9
permissions -rw-r--r--
8037816: Fix for 8036122 breaks build with Xcode5/clang Summary: Repaired or selectively disabled offending formats; future-proofed with additional checking Reviewed-by: kvn, jrose, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     1
/*
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17296
diff changeset
     2
 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     4
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     7
 * published by the Free Software Foundation.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     8
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    13
 * accompanied this code).
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    14
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    18
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    21
 * questions.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    22
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    23
 */
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    24
#include "precompiled.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    25
#include "services/nmtDCmd.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    26
#include "services/memReporter.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    27
#include "services/memTracker.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    28
#include "utilities/globalDefinitions.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    29
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    30
NMTDCmd::NMTDCmd(outputStream* output,
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    31
  bool heap): DCmdWithParser(output, heap),
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    32
  _summary("summary", "request runtime to report current memory summary, " \
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    33
           "which includes total reserved and committed memory, along " \
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    34
           "with memory usage summary by each subsytem.",
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    35
           "BOOLEAN", false, "false"),
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    36
  _detail("detail", "request runtime to report memory allocation >= "
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    37
           "1K by each callsite.",
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    38
           "BOOLEAN", false, "false"),
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    39
  _baseline("baseline", "request runtime to baseline current memory usage, " \
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    40
            "so it can be compared against in later time.",
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    41
            "BOOLEAN", false, "false"),
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    42
  _summary_diff("summary.diff", "request runtime to report memory summary " \
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    43
            "comparison against previous baseline.",
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    44
            "BOOLEAN", false, "false"),
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    45
  _detail_diff("detail.diff", "request runtime to report memory detail " \
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    46
            "comparison against previous baseline, which shows the memory " \
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    47
            "allocation activities at different callsites.",
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    48
            "BOOLEAN", false, "false"),
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    49
  _shutdown("shutdown", "request runtime to shutdown itself and free the " \
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    50
            "memory used by runtime.",
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    51
            "BOOLEAN", false, "false"),
16436
6b67e51e3cfb 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT
zgu
parents: 14819
diff changeset
    52
  _auto_shutdown("autoShutdown", "automatically shutdown itself under "    \
6b67e51e3cfb 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT
zgu
parents: 14819
diff changeset
    53
            "stress situation",
6b67e51e3cfb 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT
zgu
parents: 14819
diff changeset
    54
            "BOOLEAN", true, "true"),
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    55
#ifndef PRODUCT
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    56
  _debug("debug", "print tracker statistics. Debug only, not thread safe", \
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    57
            "BOOLEAN", false, "false"),
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    58
#endif
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    59
  _scale("scale", "Memory usage in which scale, KB, MB or GB",
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    60
       "STRING", false, "KB") {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    61
  _dcmdparser.add_dcmd_option(&_summary);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    62
  _dcmdparser.add_dcmd_option(&_detail);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    63
  _dcmdparser.add_dcmd_option(&_baseline);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    64
  _dcmdparser.add_dcmd_option(&_summary_diff);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    65
  _dcmdparser.add_dcmd_option(&_detail_diff);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    66
  _dcmdparser.add_dcmd_option(&_shutdown);
16436
6b67e51e3cfb 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT
zgu
parents: 14819
diff changeset
    67
  _dcmdparser.add_dcmd_option(&_auto_shutdown);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    68
#ifndef PRODUCT
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    69
  _dcmdparser.add_dcmd_option(&_debug);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    70
#endif
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    71
  _dcmdparser.add_dcmd_option(&_scale);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    72
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    73
17296
68557efd8583 8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents: 16436
diff changeset
    74
void NMTDCmd::execute(DCmdSource source, TRAPS) {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    75
  const char* scale_value = _scale.value();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    76
  size_t scale_unit;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    77
  if (strcmp(scale_value, "KB") == 0 || strcmp(scale_value, "kb") == 0) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    78
    scale_unit = K;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    79
  } else if (strcmp(scale_value, "MB") == 0 ||
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    80
             strcmp(scale_value, "mb") == 0) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    81
    scale_unit = M;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    82
  } else if (strcmp(scale_value, "GB") == 0 ||
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    83
             strcmp(scale_value, "gb") == 0) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    84
    scale_unit = G;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    85
  } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    86
    output()->print_cr("Incorrect scale value: %s", scale_value);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    87
    return;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    88
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    89
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    90
  int nopt = 0;
16436
6b67e51e3cfb 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT
zgu
parents: 14819
diff changeset
    91
  if (_summary.is_set() && _summary.value()) { ++nopt; }
6b67e51e3cfb 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT
zgu
parents: 14819
diff changeset
    92
  if (_detail.is_set() && _detail.value()) { ++nopt; }
6b67e51e3cfb 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT
zgu
parents: 14819
diff changeset
    93
  if (_baseline.is_set() && _baseline.value()) { ++nopt; }
6b67e51e3cfb 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT
zgu
parents: 14819
diff changeset
    94
  if (_summary_diff.is_set() && _summary_diff.value()) { ++nopt; }
6b67e51e3cfb 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT
zgu
parents: 14819
diff changeset
    95
  if (_detail_diff.is_set() && _detail_diff.value()) { ++nopt; }
6b67e51e3cfb 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT
zgu
parents: 14819
diff changeset
    96
  if (_shutdown.is_set() && _shutdown.value()) { ++nopt; }
6b67e51e3cfb 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT
zgu
parents: 14819
diff changeset
    97
  if (_auto_shutdown.is_set()) { ++nopt; }
6b67e51e3cfb 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT
zgu
parents: 14819
diff changeset
    98
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    99
#ifndef PRODUCT
16436
6b67e51e3cfb 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT
zgu
parents: 14819
diff changeset
   100
  if (_debug.is_set() && _debug.value()) { ++nopt; }
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   101
#endif
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   102
16436
6b67e51e3cfb 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT
zgu
parents: 14819
diff changeset
   103
  if (nopt > 1) {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   104
      output()->print_cr("At most one of the following option can be specified: " \
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   105
        "summary, detail, baseline, summary.diff, detail.diff, shutdown"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   106
#ifndef PRODUCT
14819
15be618136c6 8004802: jcmd VM.native_memory baseline=false crashes VM
zgu
parents: 13195
diff changeset
   107
        ", debug"
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   108
#endif
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   109
      );
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   110
      return;
14819
15be618136c6 8004802: jcmd VM.native_memory baseline=false crashes VM
zgu
parents: 13195
diff changeset
   111
  } else if (nopt == 0) {
15be618136c6 8004802: jcmd VM.native_memory baseline=false crashes VM
zgu
parents: 13195
diff changeset
   112
    if (_summary.is_set()) {
15be618136c6 8004802: jcmd VM.native_memory baseline=false crashes VM
zgu
parents: 13195
diff changeset
   113
      output()->print_cr("No command to execute");
15be618136c6 8004802: jcmd VM.native_memory baseline=false crashes VM
zgu
parents: 13195
diff changeset
   114
      return;
15be618136c6 8004802: jcmd VM.native_memory baseline=false crashes VM
zgu
parents: 13195
diff changeset
   115
    } else {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   116
      _summary.set_value(true);
14819
15be618136c6 8004802: jcmd VM.native_memory baseline=false crashes VM
zgu
parents: 13195
diff changeset
   117
    }
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   118
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   119
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   120
#ifndef PRODUCT
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   121
  if (_debug.value()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   122
    output()->print_cr("debug command is NOT thread-safe, may cause crash");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   123
    MemTracker::print_tracker_stats(output());
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   124
    return;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   125
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   126
#endif
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   127
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   128
  // native memory tracking has to be on
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   129
  if (!MemTracker::is_on() || MemTracker::shutdown_in_progress()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   130
    // if it is not on, what's the reason?
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17296
diff changeset
   131
    output()->print_cr("%s", MemTracker::reason());
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   132
    return;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   133
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   134
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   135
  if (_summary.value()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   136
    BaselineTTYOutputer outputer(output());
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   137
    MemTracker::print_memory_usage(outputer, scale_unit, true);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   138
  } else if (_detail.value()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   139
    BaselineTTYOutputer outputer(output());
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   140
    MemTracker::print_memory_usage(outputer, scale_unit, false);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   141
  } else if (_baseline.value()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   142
    if (MemTracker::baseline()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   143
      output()->print_cr("Successfully baselined.");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   144
    } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   145
      output()->print_cr("Baseline failed.");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   146
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   147
  } else if (_summary_diff.value()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   148
    if (MemTracker::has_baseline()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   149
      BaselineTTYOutputer outputer(output());
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   150
      MemTracker::compare_memory_usage(outputer, scale_unit, true);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   151
    } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   152
      output()->print_cr("No baseline to compare, run 'baseline' command first");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   153
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   154
  } else if (_detail_diff.value()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   155
    if (MemTracker::has_baseline()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   156
      BaselineTTYOutputer outputer(output());
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   157
      MemTracker::compare_memory_usage(outputer, scale_unit, false);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   158
    } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   159
      output()->print_cr("No baseline to compare to, run 'baseline' command first");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   160
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   161
  } else if (_shutdown.value()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   162
    MemTracker::shutdown(MemTracker::NMT_shutdown_user);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   163
    output()->print_cr("Shutdown is in progress, it will take a few moments to " \
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   164
      "completely shutdown");
16436
6b67e51e3cfb 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT
zgu
parents: 14819
diff changeset
   165
  } else if (_auto_shutdown.is_set()) {
6b67e51e3cfb 8009298: NMT: Special version of class loading/unloading with runThese stresses out NMT
zgu
parents: 14819
diff changeset
   166
    MemTracker::set_autoShutdown(_auto_shutdown.value());
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   167
  } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   168
    ShouldNotReachHere();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   169
    output()->print_cr("Unknown command");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   170
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   171
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   172
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   173
int NMTDCmd::num_arguments() {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   174
  ResourceMark rm;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   175
  NMTDCmd* dcmd = new NMTDCmd(NULL, false);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   176
  if (dcmd != NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   177
    DCmdMark mark(dcmd);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   178
    return dcmd->_dcmdparser.num_arguments();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   179
  } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   180
    return 0;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   181
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   182
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   183