Path: blob/master/src/hotspot/share/gc/serial/cSpaceCounters.cpp
41149 views
/*1* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "gc/serial/cSpaceCounters.hpp"26#include "memory/allocation.inline.hpp"27#include "memory/resourceArea.hpp"2829CSpaceCounters::CSpaceCounters(const char* name, int ordinal, size_t max_size,30ContiguousSpace* s, GenerationCounters* gc) :31_space(s) {3233if (UsePerfData) {34EXCEPTION_MARK;35ResourceMark rm;3637const char* cns = PerfDataManager::name_space(gc->name_space(), "space",38ordinal);3940_name_space = NEW_C_HEAP_ARRAY(char, strlen(cns)+1, mtGC);41strcpy(_name_space, cns);4243const char* cname = PerfDataManager::counter_name(_name_space, "name");44PerfDataManager::create_string_constant(SUN_GC, cname, name, CHECK);4546cname = PerfDataManager::counter_name(_name_space, "maxCapacity");47_max_capacity = PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes,48(jlong)max_size, CHECK);4950cname = PerfDataManager::counter_name(_name_space, "capacity");51_capacity = PerfDataManager::create_variable(SUN_GC, cname,52PerfData::U_Bytes,53_space->capacity(), CHECK);5455cname = PerfDataManager::counter_name(_name_space, "used");56_used = PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes,57new ContiguousSpaceUsedHelper(_space),58CHECK);5960cname = PerfDataManager::counter_name(_name_space, "initCapacity");61PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes,62_space->capacity(), CHECK);63}64}6566CSpaceCounters::~CSpaceCounters() {67FREE_C_HEAP_ARRAY(char, _name_space);68}6970void CSpaceCounters::update_capacity() {71_capacity->set_value(_space->capacity());72}7374void CSpaceCounters::update_used() {75_used->set_value(_space->used());76}7778void CSpaceCounters::update_all() {79update_used();80update_capacity();81}8283jlong ContiguousSpaceUsedHelper::take_sample(){84return _space->used();85}868788