Path: blob/master/src/hotspot/share/memory/metaspaceStats.hpp
40949 views
/*1* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2021 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*/24#ifndef SHARE_MEMORY_METASPACESTATS_HPP25#define SHARE_MEMORY_METASPACESTATS_HPP2627#include "utilities/globalDefinitions.hpp"2829// Data holder classes for metaspace statistics.30//31// - MetaspaceStats: keeps reserved, committed and used byte counters;32// retrieve with MetaspaceUtils::get_statistics(MetadataType) for either class space33// or non-class space34//35// - MetaspaceCombinedStats: keeps reserved, committed and used byte counters, seperately for both class- and non-class-space;36// retrieve with MetaspaceUtils::get_combined_statistics()3738// (Note: just for NMT these objects need to be mutable)3940class MetaspaceStats {41size_t _reserved;42size_t _committed;43size_t _used;44public:45MetaspaceStats() : _reserved(0), _committed(0), _used(0) {}46MetaspaceStats(size_t r, size_t c, size_t u) : _reserved(r), _committed(c), _used(u) {}47size_t used() const { return _used; }48size_t committed() const { return _committed; }49size_t reserved() const { return _reserved; }50};5152// Class holds combined statistics for both non-class and class space.53class MetaspaceCombinedStats : public MetaspaceStats {54MetaspaceStats _cstats; // class space stats55MetaspaceStats _ncstats; // non-class space stats56public:57MetaspaceCombinedStats() {}58MetaspaceCombinedStats(const MetaspaceStats& cstats, const MetaspaceStats& ncstats) :59MetaspaceStats(cstats.reserved() + ncstats.reserved(),60cstats.committed() + ncstats.committed(),61cstats.used() + ncstats.used()),62_cstats(cstats), _ncstats(ncstats)63{}6465const MetaspaceStats& class_space_stats() const { return _cstats; }66const MetaspaceStats& non_class_space_stats() const { return _ncstats; }67size_t class_used() const { return _cstats.used(); }68size_t class_committed() const { return _cstats.committed(); }69size_t class_reserved() const { return _cstats.reserved(); }70size_t non_class_used() const { return _ncstats.used(); }71size_t non_class_committed() const { return _ncstats.committed(); }72size_t non_class_reserved() const { return _ncstats.reserved(); }73};7475#endif // SHARE_MEMORY_METASPACESTATS_HPP767778