1 /*
 2  * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
 3  * Copyright (c) 2020, 2022 SAP SE. All rights reserved.
 4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 5  *
 6  * This code is free software; you can redistribute it and/or modify it
 7  * under the terms of the GNU General Public License version 2 only, as
 8  * published by the Free Software Foundation.
 9  *
10  * This code is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13  * version 2 for more details (a copy is included in the LICENSE file that
14  * accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License version
17  * 2 along with this work; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19  *
20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21  * or visit www.oracle.com if you need additional information or have any
22  * questions.
23  *
24  */
25 
26 #ifndef SHARE_MEMORY_METASPACE_RUNNINGCOUNTERS_HPP
27 #define SHARE_MEMORY_METASPACE_RUNNINGCOUNTERS_HPP
28 
29 #include "memory/allStatic.hpp"
30 #include "memory/metaspace/counters.hpp"
31 
32 namespace metaspace {
33 
34 // This class is a convenience interface for accessing global metaspace counters.
35 class RunningCounters : public AllStatic {
36 
37   static SizeAtomicCounter _used_class_counter;
38   static SizeAtomicCounter _used_nonclass_counter;
39 
40 public:
41 
42   // ---- virtual memory -----
43 
44   // Return reserved size, in words, for Metaspace
45   static size_t reserved_words();
46   static size_t reserved_words_class();
47   static size_t reserved_words_nonclass();
48 
49   // Return total committed size, in words, for Metaspace
50   static size_t committed_words();
51   static size_t committed_words_class();
52   static size_t committed_words_nonclass();
53 
54   // ---- used chunks -----
55 
56   // Returns size, in words, used for metadata.
57   static size_t used_words();
58   static size_t used_words_class();
59   static size_t used_words_nonclass();
60 
61   // ---- free chunks -----
62 
63   // Returns size, in words, of all chunks in all freelists.
64   static size_t free_chunks_words();
65   static size_t free_chunks_words_class();
66   static size_t free_chunks_words_nonclass();
67 
68   // Direct access to the counters.
69   static SizeAtomicCounter* used_nonclass_counter()     { return &_used_nonclass_counter; }
70   static SizeAtomicCounter* used_class_counter()        { return &_used_class_counter; }
71 
72 };
73 
74 } // namespace metaspace
75 
76 #endif // SHARE_MEMORY_METASPACE_RUNNINGCOUNTERS_HPP