src/share/vm/memory/metaspaceCounters.cpp

Thu, 17 Jan 2013 19:04:48 -0800

author
jmasa
date
Thu, 17 Jan 2013 19:04:48 -0800
changeset 4457
59a58e20dc60
parent 4376
79f492f184d0
child 4680
0624b9d81255
permissions
-rw-r--r--

8006537: Assert when dumping archive with default methods
Reviewed-by: coleenp

coleenp@4037 1 /*
katleman@4376 2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
coleenp@4037 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
coleenp@4037 4 *
coleenp@4037 5 * This code is free software; you can redistribute it and/or modify it
coleenp@4037 6 * under the terms of the GNU General Public License version 2 only, as
coleenp@4037 7 * published by the Free Software Foundation.
coleenp@4037 8 *
coleenp@4037 9 * This code is distributed in the hope that it will be useful, but WITHOUT
coleenp@4037 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
coleenp@4037 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
coleenp@4037 12 * version 2 for more details (a copy is included in the LICENSE file that
coleenp@4037 13 * accompanied this code).
coleenp@4037 14 *
coleenp@4037 15 * You should have received a copy of the GNU General Public License version
coleenp@4037 16 * 2 along with this work; if not, write to the Free Software Foundation,
coleenp@4037 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
coleenp@4037 18 *
coleenp@4037 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
coleenp@4037 20 * or visit www.oracle.com if you need additional information or have any
coleenp@4037 21 * questions.
coleenp@4037 22 *
coleenp@4037 23 */
coleenp@4037 24
coleenp@4037 25 #include "precompiled.hpp"
coleenp@4037 26 #include "memory/metaspaceCounters.hpp"
coleenp@4037 27 #include "memory/resourceArea.hpp"
coleenp@4037 28
coleenp@4037 29 #define METASPACE_NAME "perm"
coleenp@4037 30
coleenp@4037 31 MetaspaceCounters* MetaspaceCounters::_metaspace_counters = NULL;
coleenp@4037 32
coleenp@4037 33 MetaspaceCounters::MetaspaceCounters() {
coleenp@4037 34 if (UsePerfData) {
coleenp@4037 35 size_t min_capacity = MetaspaceAux::min_chunk_size();
coleenp@4037 36 size_t max_capacity = MetaspaceAux::reserved_in_bytes();
coleenp@4037 37 size_t curr_capacity = MetaspaceAux::capacity_in_bytes();
jmasa@4046 38 size_t used = MetaspaceAux::used_in_bytes();
coleenp@4037 39
coleenp@4037 40 initialize(min_capacity, max_capacity, curr_capacity, used);
coleenp@4037 41 }
coleenp@4037 42 }
coleenp@4037 43
coleenp@4037 44 void MetaspaceCounters::initialize(size_t min_capacity,
coleenp@4037 45 size_t max_capacity,
coleenp@4037 46 size_t curr_capacity,
coleenp@4037 47 size_t used) {
coleenp@4037 48
coleenp@4037 49 if (UsePerfData) {
coleenp@4037 50 EXCEPTION_MARK;
coleenp@4037 51 ResourceMark rm;
coleenp@4037 52
coleenp@4037 53 // Create a name that will be recognized by jstat tools as
coleenp@4037 54 // the perm gen. Change this to a Metaspace name when the
coleenp@4037 55 // tools are fixed.
coleenp@4037 56 // name to recognize "sun.gc.generation.2.*"
coleenp@4037 57
coleenp@4037 58 const char* name = METASPACE_NAME;
coleenp@4037 59 const int ordinal = 2;
coleenp@4037 60 const int spaces = 1;
coleenp@4037 61
coleenp@4037 62 const char* cns = PerfDataManager::name_space("generation", ordinal);
coleenp@4037 63
coleenp@4037 64 _name_space = NEW_C_HEAP_ARRAY(char, strlen(cns)+1, mtClass);
coleenp@4037 65 strcpy(_name_space, cns);
coleenp@4037 66
coleenp@4037 67 const char* cname = PerfDataManager::counter_name(_name_space, "name");
coleenp@4037 68 PerfDataManager::create_string_constant(SUN_GC, cname, name, CHECK);
coleenp@4037 69
coleenp@4037 70 // End of perm gen like name creation
coleenp@4037 71
coleenp@4037 72 cname = PerfDataManager::counter_name(_name_space, "spaces");
coleenp@4037 73 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_None,
coleenp@4037 74 spaces, CHECK);
coleenp@4037 75
coleenp@4037 76 cname = PerfDataManager::counter_name(_name_space, "minCapacity");
coleenp@4037 77 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes,
coleenp@4037 78 min_capacity, CHECK);
coleenp@4037 79
coleenp@4037 80 cname = PerfDataManager::counter_name(_name_space, "maxCapacity");
coleenp@4037 81 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes,
coleenp@4037 82 max_capacity, CHECK);
coleenp@4037 83
coleenp@4037 84 cname = PerfDataManager::counter_name(_name_space, "capacity");
coleenp@4037 85 _current_size =
coleenp@4037 86 PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes,
coleenp@4037 87 curr_capacity, CHECK);
coleenp@4037 88
coleenp@4037 89 // SpaceCounter like counters
coleenp@4037 90 // name to recognize "sun.gc.generation.2.space.0.*"
coleenp@4037 91 {
coleenp@4037 92 const int space_ordinal = 0;
coleenp@4037 93 const char* cns = PerfDataManager::name_space(_name_space, "space",
coleenp@4037 94 space_ordinal);
coleenp@4037 95
coleenp@4037 96 char* space_name_space = NEW_C_HEAP_ARRAY(char, strlen(cns)+1, mtClass);
coleenp@4037 97 strcpy(space_name_space, cns);
coleenp@4037 98
coleenp@4037 99 const char* cname = PerfDataManager::counter_name(space_name_space, "name");
coleenp@4037 100 PerfDataManager::create_string_constant(SUN_GC, cname, name, CHECK);
coleenp@4037 101
coleenp@4037 102 cname = PerfDataManager::counter_name(space_name_space, "maxCapacity");
coleenp@4037 103 _max_capacity = PerfDataManager::create_variable(SUN_GC, cname,
coleenp@4037 104 PerfData::U_Bytes,
coleenp@4037 105 (jlong)max_capacity, CHECK);
coleenp@4037 106
coleenp@4037 107 cname = PerfDataManager::counter_name(space_name_space, "capacity");
coleenp@4037 108 _capacity = PerfDataManager::create_variable(SUN_GC, cname,
coleenp@4037 109 PerfData::U_Bytes,
coleenp@4037 110 curr_capacity, CHECK);
coleenp@4037 111
coleenp@4037 112 cname = PerfDataManager::counter_name(space_name_space, "used");
coleenp@4037 113 _used = PerfDataManager::create_variable(SUN_GC,
coleenp@4037 114 cname,
coleenp@4037 115 PerfData::U_Bytes,
coleenp@4037 116 used,
coleenp@4037 117 CHECK);
coleenp@4037 118
coleenp@4037 119 cname = PerfDataManager::counter_name(space_name_space, "initCapacity");
coleenp@4037 120 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes,
coleenp@4037 121 min_capacity, CHECK);
coleenp@4037 122 }
coleenp@4037 123 }
coleenp@4037 124 }
coleenp@4037 125
coleenp@4037 126 void MetaspaceCounters::update_capacity() {
coleenp@4037 127 assert(UsePerfData, "Should not be called unless being used");
coleenp@4037 128 size_t capacity_in_bytes = MetaspaceAux::capacity_in_bytes();
coleenp@4037 129 _capacity->set_value(capacity_in_bytes);
coleenp@4037 130 }
coleenp@4037 131
coleenp@4037 132 void MetaspaceCounters::update_used() {
coleenp@4037 133 assert(UsePerfData, "Should not be called unless being used");
jmasa@4046 134 size_t used_in_bytes = MetaspaceAux::used_in_bytes();
coleenp@4037 135 _used->set_value(used_in_bytes);
coleenp@4037 136 }
coleenp@4037 137
coleenp@4037 138 void MetaspaceCounters::update_max_capacity() {
coleenp@4037 139 assert(UsePerfData, "Should not be called unless being used");
coleenp@4037 140 size_t reserved_in_bytes = MetaspaceAux::reserved_in_bytes();
coleenp@4037 141 _max_capacity->set_value(reserved_in_bytes);
coleenp@4037 142 }
coleenp@4037 143
coleenp@4037 144 void MetaspaceCounters::update_all() {
coleenp@4037 145 if (UsePerfData) {
coleenp@4037 146 update_used();
coleenp@4037 147 update_capacity();
coleenp@4037 148 update_max_capacity();
coleenp@4037 149 _current_size->set_value(MetaspaceAux::reserved_in_bytes());
coleenp@4037 150 }
coleenp@4037 151 }
coleenp@4037 152
coleenp@4037 153 void MetaspaceCounters::initialize_performance_counters() {
coleenp@4037 154 if (UsePerfData) {
coleenp@4037 155 _metaspace_counters = new MetaspaceCounters();
coleenp@4037 156 }
coleenp@4037 157 }
coleenp@4037 158
coleenp@4037 159 void MetaspaceCounters::update_performance_counters() {
coleenp@4037 160 if (UsePerfData) {
coleenp@4037 161 _metaspace_counters->update_all();
coleenp@4037 162 }
coleenp@4037 163 }
coleenp@4037 164

mercurial