Path: blob/master/src/hotspot/share/memory/metaspace/runningCounters.cpp
40957 views
/*1* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2020 SAP SE. All rights reserved.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#include "precompiled.hpp"26#include "memory/metaspace/chunkManager.hpp"27#include "memory/metaspace/counters.hpp"28#include "memory/metaspace/runningCounters.hpp"29#include "memory/metaspace/virtualSpaceList.hpp"3031namespace metaspace {3233SizeAtomicCounter RunningCounters::_used_class_counter;34SizeAtomicCounter RunningCounters::_used_nonclass_counter;3536// Return reserved size, in words, for Metaspace37size_t RunningCounters::reserved_words() {38return reserved_words_class() + reserved_words_nonclass();39}4041size_t RunningCounters::reserved_words_class() {42VirtualSpaceList* vs = VirtualSpaceList::vslist_class();43return vs != NULL ? vs->reserved_words() : 0;44}4546size_t RunningCounters::reserved_words_nonclass() {47return VirtualSpaceList::vslist_nonclass()->reserved_words();48}4950// Return total committed size, in words, for Metaspace51size_t RunningCounters::committed_words() {52return committed_words_class() + committed_words_nonclass();53}5455size_t RunningCounters::committed_words_class() {56VirtualSpaceList* vs = VirtualSpaceList::vslist_class();57return vs != NULL ? vs->committed_words() : 0;58}5960size_t RunningCounters::committed_words_nonclass() {61return VirtualSpaceList::vslist_nonclass()->committed_words();62}6364// ---- used chunks -----6566// Returns size, in words, used for metadata.67size_t RunningCounters::used_words() {68return used_words_class() + used_words_nonclass();69}7071size_t RunningCounters::used_words_class() {72return _used_class_counter.get();73}7475size_t RunningCounters::used_words_nonclass() {76return _used_nonclass_counter.get();77}7879// ---- free chunks -----8081// Returns size, in words, of all chunks in all freelists.82size_t RunningCounters::free_chunks_words() {83return free_chunks_words_class() + free_chunks_words_nonclass();84}8586size_t RunningCounters::free_chunks_words_class() {87ChunkManager* cm = ChunkManager::chunkmanager_class();88return cm != NULL ? cm->total_word_size() : 0;89}9091size_t RunningCounters::free_chunks_words_nonclass() {92return ChunkManager::chunkmanager_nonclass()->total_word_size();93}9495} // namespace metaspace96979899