Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/src/hotspot/share/memory/metaspace/metaspaceDCmd.cpp
66644 views
1
/*
2
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
3
* Copyright (c) 2018, 2020 SAP SE. All rights reserved.
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
*
6
* This code is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License version 2 only, as
8
* published by the Free Software Foundation.
9
*
10
* This code is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* version 2 for more details (a copy is included in the LICENSE file that
14
* accompanied this code).
15
*
16
* You should have received a copy of the GNU General Public License version
17
* 2 along with this work; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
*
20
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
* or visit www.oracle.com if you need additional information or have any
22
* questions.
23
*
24
*/
25
26
#include "precompiled.hpp"
27
#include "memory/metaspace.hpp"
28
#include "memory/metaspace/metaspaceDCmd.hpp"
29
#include "memory/metaspace/metaspaceReporter.hpp"
30
#include "memory/metaspaceUtils.hpp"
31
#include "memory/resourceArea.hpp"
32
#include "runtime/vmOperations.hpp"
33
#include "services/diagnosticCommand.hpp"
34
#include "services/nmtCommon.hpp"
35
36
namespace metaspace {
37
38
MetaspaceDCmd::MetaspaceDCmd(outputStream* output, bool heap) :
39
DCmdWithParser(output, heap),
40
_basic("basic", "Prints a basic summary (does not need a safepoint).", "BOOLEAN", false, "false"),
41
_show_loaders("show-loaders", "Shows usage by class loader.", "BOOLEAN", false, "false"),
42
_by_spacetype("by-spacetype", "Break down numbers by loader type.", "BOOLEAN", false, "false"),
43
_by_chunktype("by-chunktype", "Break down numbers by chunk type.", "BOOLEAN", false, "false"),
44
_show_vslist("vslist", "Shows details about the underlying virtual space.", "BOOLEAN", false, "false"),
45
_show_chunkfreelist("chunkfreelist", "Shows details about global chunk free lists (ChunkManager).", "BOOLEAN", false, "false"),
46
_scale("scale", "Memory usage in which to scale. Valid values are: 1, KB, MB or GB (fixed scale) "
47
"or \"dynamic\" for a dynamically choosen scale.",
48
"STRING", false, "dynamic"),
49
_show_classes("show-classes", "If show-loaders is set, shows loaded classes for each loader.", "BOOLEAN", false, "false")
50
{
51
_dcmdparser.add_dcmd_option(&_basic);
52
_dcmdparser.add_dcmd_option(&_show_loaders);
53
_dcmdparser.add_dcmd_option(&_show_classes);
54
_dcmdparser.add_dcmd_option(&_by_chunktype);
55
_dcmdparser.add_dcmd_option(&_by_spacetype);
56
_dcmdparser.add_dcmd_option(&_show_vslist);
57
_dcmdparser.add_dcmd_option(&_show_chunkfreelist);
58
_dcmdparser.add_dcmd_option(&_scale);
59
}
60
61
int MetaspaceDCmd::num_arguments() {
62
ResourceMark rm;
63
MetaspaceDCmd* dcmd = new MetaspaceDCmd(NULL, false);
64
if (dcmd != NULL) {
65
DCmdMark mark(dcmd);
66
return dcmd->_dcmdparser.num_arguments();
67
} else {
68
return 0;
69
}
70
}
71
72
void MetaspaceDCmd::execute(DCmdSource source, TRAPS) {
73
// Parse scale value.
74
const char* scale_value = _scale.value();
75
size_t scale = 0;
76
if (scale_value != NULL) {
77
if (strcasecmp("dynamic", scale_value) == 0) {
78
scale = 0;
79
} else {
80
scale = NMT_ONLY(NMTUtil::scale_from_name(scale_value)) NOT_NMT(0);
81
if (scale == 0) {
82
output()->print_cr("Invalid scale: \"%s\". Will use dynamic scaling.", scale_value);
83
}
84
}
85
}
86
if (_basic.value() == true) {
87
if (_show_loaders.value() || _by_chunktype.value() || _by_spacetype.value() ||
88
_show_vslist.value()) {
89
// Basic mode. Just print essentials. Does not need to be at a safepoint.
90
output()->print_cr("In basic mode, additional arguments are ignored.");
91
}
92
MetaspaceUtils::print_basic_report(output(), scale);
93
} else {
94
// Full mode. Requires safepoint.
95
int flags = 0;
96
if (_show_loaders.value()) flags |= (int)MetaspaceReporter::Option::ShowLoaders;
97
if (_show_classes.value()) flags |= (int)MetaspaceReporter::Option::ShowClasses;
98
if (_by_chunktype.value()) flags |= (int)MetaspaceReporter::Option::BreakDownByChunkType;
99
if (_by_spacetype.value()) flags |= (int)MetaspaceReporter::Option::BreakDownBySpaceType;
100
if (_show_vslist.value()) flags |= (int)MetaspaceReporter::Option::ShowVSList;
101
if (_show_chunkfreelist.value()) flags |= (int)MetaspaceReporter::Option::ShowChunkFreeList;
102
VM_PrintMetadata op(output(), scale, flags);
103
VMThread::execute(&op);
104
}
105
}
106
107
} // namespace metaspace
108
109
110