annotate src/share/vm/gc_implementation/shared/hSpaceCounters.cpp @ 3465:d2a62e0f25eb

6995781: Native Memory Tracking (Phase 1) 7151532: DCmd for hotspot native memory tracking Summary: Implementation of native memory tracking phase 1, which tracks VM native memory usage, and related DCmd Reviewed-by: acorn, coleenp, fparain
author zgu
date Thu, 28 Jun 2012 17:03:16 -0400
parents b52782ae3880
children b9a9ed0f8eeb
rev   line source
jmasa@2386 1 /*
jmasa@2386 2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
jmasa@2386 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jmasa@2386 4 *
jmasa@2386 5 * This code is free software; you can redistribute it and/or modify it
jmasa@2386 6 * under the terms of the GNU General Public License version 2 only, as
jmasa@2386 7 * published by the Free Software Foundation.
jmasa@2386 8 *
jmasa@2386 9 * This code is distributed in the hope that it will be useful, but WITHOUT
jmasa@2386 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jmasa@2386 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jmasa@2386 12 * version 2 for more details (a copy is included in the LICENSE file that
jmasa@2386 13 * accompanied this code).
jmasa@2386 14 *
jmasa@2386 15 * You should have received a copy of the GNU General Public License version
jmasa@2386 16 * 2 along with this work; if not, write to the Free Software Foundation,
jmasa@2386 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jmasa@2386 18 *
jmasa@2386 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jmasa@2386 20 * or visit www.oracle.com if you need additional information or have any
jmasa@2386 21 * questions.
jmasa@2386 22 *
jmasa@2386 23 */
jmasa@2386 24
jmasa@2386 25 #include "precompiled.hpp"
jmasa@2386 26 #include "gc_implementation/shared/hSpaceCounters.hpp"
jmasa@2386 27 #include "memory/generation.hpp"
jmasa@2386 28 #include "memory/resourceArea.hpp"
jmasa@2386 29
jmasa@2386 30 HSpaceCounters::HSpaceCounters(const char* name,
jmasa@2386 31 int ordinal,
jmasa@2386 32 size_t max_size,
jmasa@2386 33 size_t initial_capacity,
jmasa@2386 34 GenerationCounters* gc) {
jmasa@2386 35
jmasa@2386 36 if (UsePerfData) {
jmasa@2386 37 EXCEPTION_MARK;
jmasa@2386 38 ResourceMark rm;
jmasa@2386 39
jmasa@2386 40 const char* cns =
jmasa@2386 41 PerfDataManager::name_space(gc->name_space(), "space", ordinal);
jmasa@2386 42
zgu@3465 43 _name_space = NEW_C_HEAP_ARRAY(char, strlen(cns)+1, mtGC);
jmasa@2386 44 strcpy(_name_space, cns);
jmasa@2386 45
jmasa@2386 46 const char* cname = PerfDataManager::counter_name(_name_space, "name");
jmasa@2386 47 PerfDataManager::create_string_constant(SUN_GC, cname, name, CHECK);
jmasa@2386 48
jmasa@2386 49 cname = PerfDataManager::counter_name(_name_space, "maxCapacity");
jmasa@2386 50 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes,
jmasa@2386 51 (jlong)max_size, CHECK);
jmasa@2386 52
jmasa@2386 53 cname = PerfDataManager::counter_name(_name_space, "capacity");
jmasa@2386 54 _capacity = PerfDataManager::create_variable(SUN_GC, cname,
jmasa@2386 55 PerfData::U_Bytes,
jmasa@2386 56 initial_capacity, CHECK);
jmasa@2386 57
jmasa@2386 58 cname = PerfDataManager::counter_name(_name_space, "used");
jmasa@2386 59 _used = PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes,
jmasa@2386 60 (jlong) 0, CHECK);
jmasa@2386 61
jmasa@2386 62 cname = PerfDataManager::counter_name(_name_space, "initCapacity");
jmasa@2386 63 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes,
jmasa@2386 64 initial_capacity, CHECK);
jmasa@2386 65 }
jmasa@2386 66 }