annotate src/share/vm/gc_implementation/shared/generationCounters.cpp @ 2741:8229bd737950

7075646: G1: fix inconsistencies in the monitoring data Summary: Fixed a few inconsistencies in the monitoring data, in particular when reported from jstat. Reviewed-by: jmasa, brutisso, johnc
author tonyp
date Fri, 23 Sep 2011 16:07:49 -0400
parents b52782ae3880
children d2a62e0f25eb
rev   line source
duke@0 1 /*
jmasa@2386 2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
stefank@1879 25 #include "precompiled.hpp"
stefank@1879 26 #include "gc_implementation/shared/generationCounters.hpp"
stefank@1879 27 #include "memory/resourceArea.hpp"
duke@0 28
tonyp@2741 29 void GenerationCounters::initialize(const char* name, int ordinal, int spaces,
tonyp@2741 30 size_t min_capacity, size_t max_capacity,
tonyp@2741 31 size_t curr_capacity) {
duke@0 32 if (UsePerfData) {
duke@0 33 EXCEPTION_MARK;
duke@0 34 ResourceMark rm;
duke@0 35
duke@0 36 const char* cns = PerfDataManager::name_space("generation", ordinal);
duke@0 37
duke@0 38 _name_space = NEW_C_HEAP_ARRAY(char, strlen(cns)+1);
duke@0 39 strcpy(_name_space, cns);
duke@0 40
duke@0 41 const char* cname = PerfDataManager::counter_name(_name_space, "name");
duke@0 42 PerfDataManager::create_string_constant(SUN_GC, cname, name, CHECK);
duke@0 43
duke@0 44 cname = PerfDataManager::counter_name(_name_space, "spaces");
duke@0 45 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_None,
duke@0 46 spaces, CHECK);
duke@0 47
duke@0 48 cname = PerfDataManager::counter_name(_name_space, "minCapacity");
duke@0 49 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes,
tonyp@2741 50 min_capacity, CHECK);
duke@0 51
duke@0 52 cname = PerfDataManager::counter_name(_name_space, "maxCapacity");
duke@0 53 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes,
tonyp@2741 54 max_capacity, CHECK);
duke@0 55
duke@0 56 cname = PerfDataManager::counter_name(_name_space, "capacity");
tonyp@2741 57 _current_size =
tonyp@2741 58 PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes,
tonyp@2741 59 curr_capacity, CHECK);
duke@0 60 }
duke@0 61 }
tonyp@2741 62
tonyp@2741 63 GenerationCounters::GenerationCounters(const char* name,
tonyp@2741 64 int ordinal, int spaces,
tonyp@2741 65 VirtualSpace* v)
tonyp@2741 66 : _virtual_space(v) {
tonyp@2741 67 assert(v != NULL, "don't call this constructor if v == NULL");
tonyp@2741 68 initialize(name, ordinal, spaces,
tonyp@2741 69 v->committed_size(), v->reserved_size(), v->committed_size());
tonyp@2741 70 }
tonyp@2741 71
tonyp@2741 72 GenerationCounters::GenerationCounters(const char* name,
tonyp@2741 73 int ordinal, int spaces,
tonyp@2741 74 size_t min_capacity, size_t max_capacity,
tonyp@2741 75 size_t curr_capacity)
tonyp@2741 76 : _virtual_space(NULL) {
tonyp@2741 77 initialize(name, ordinal, spaces, min_capacity, max_capacity, curr_capacity);
tonyp@2741 78 }
tonyp@2741 79
tonyp@2741 80 void GenerationCounters::update_all() {
tonyp@2741 81 assert(_virtual_space != NULL, "otherwise, override this method");
tonyp@2741 82 _current_size->set_value(_virtual_space->committed_size());
tonyp@2741 83 }