/* * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/ #include"precompiled.hpp" #include"memory/resourceArea.hpp" #include"runtime/mutexLocker.hpp" #include"runtime/vmThread.hpp" #include"runtime/vmOperations.hpp" #include"services/nmtDCmd.hpp" #include"services/memReporter.hpp" #include"services/memTracker.hpp" #include"utilities/globalDefinitions.hpp"
NMTDCmd::NMTDCmd(outputStream* output, bool heap): DCmdWithParser(output, heap),
_summary("summary", "request runtime to report current memory summary, " \ "which includes total reserved and committed memory, along " \ "with memory usage summary by each subsystem.", "BOOLEAN", false, "false"),
_detail("detail", "request runtime to report memory allocation >= " "1K by each callsite.", "BOOLEAN", false, "false"),
_baseline("baseline", "request runtime to baseline current memory usage, " \ "so it can be compared against in later time.", "BOOLEAN", false, "false"),
_summary_diff("summary.diff", "request runtime to report memory summary " \ "comparison against previous baseline.", "BOOLEAN", false, "false"),
_detail_diff("detail.diff", "request runtime to report memory detail " \ "comparison against previous baseline, which shows the memory " \ "allocation activities at different callsites.", "BOOLEAN", false, "false"),
_statistics("statistics", "print tracker statistics for tuning purpose.", \ "BOOLEAN", false, "false"),
_scale("scale", "Memory usage in which scale, KB, MB or GB", "STRING", false, "KB") {
_dcmdparser.add_dcmd_option(&_summary);
_dcmdparser.add_dcmd_option(&_detail);
_dcmdparser.add_dcmd_option(&_baseline);
_dcmdparser.add_dcmd_option(&_summary_diff);
_dcmdparser.add_dcmd_option(&_detail_diff);
_dcmdparser.add_dcmd_option(&_statistics);
_dcmdparser.add_dcmd_option(&_scale);
}
void NMTDCmd::execute(DCmdSource source, TRAPS) { // Check NMT state // native memory tracking has to be on if (MemTracker::tracking_level() == NMT_off) {
output()->print_cr("Native memory tracking is not enabled"); return;
}
int nopt = 0; if (_summary.is_set() && _summary.value()) { ++nopt; } if (_detail.is_set() && _detail.value()) { ++nopt; } if (_baseline.is_set() && _baseline.value()) { ++nopt; } if (_summary_diff.is_set() && _summary_diff.value()) { ++nopt; } if (_detail_diff.is_set() && _detail_diff.value()) { ++nopt; } if (_statistics.is_set() && _statistics.value()) { ++nopt; }
if (nopt > 1) {
output()->print_cr("At most one of the following option can be specified: " \ "summary, detail, metadata, baseline, summary.diff, detail.diff"); return;
} elseif (nopt == 0) { if (_summary.is_set()) {
output()->print_cr("No command to execute"); return;
} else {
_summary.set_value(true);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.