1 /*
   2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. 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 it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 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 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_MEMORY_METASPACE_METASPACEREPORT_HPP
  26 #define SHARE_MEMORY_METASPACE_METASPACEREPORT_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 
  30 namespace metaspace {
  31 
  32 class MetaspaceReporter : public AllStatic {
  33 public:
  34 
  35   // Flags for print_report().
  36   enum ReportFlag {
  37     // Show usage by class loader.
  38     rf_show_loaders                 = (1 << 0),
  39     // Breaks report down by chunk type (small, medium, ...).
  40     rf_break_down_by_chunktype      = (1 << 1),
  41     // Breaks report down by space type (anonymous, reflection, ...).
  42     rf_break_down_by_spacetype      = (1 << 2),
  43     // Print details about the underlying virtual spaces.
  44     rf_show_vslist                  = (1 << 3),
  45     // Print metaspace map.
  46     rf_show_vsmap                   = (1 << 4),
  47     // If show_loaders: show loaded classes for each loader.
  48     rf_show_classes                 = (1 << 5)
  49   };
  50 
  51   // This will print out a basic metaspace usage report but
  52   // unlike print_report() is guaranteed not to lock or to walk the CLDG.
  53   static void print_basic_report(outputStream* st, size_t scale);
  54 
  55   // Prints a report about the current metaspace state.
  56   // Optional parts can be enabled via flags.
  57   // Function will walk the CLDG and will lock the expand lock; if that is not
  58   // convenient, use print_basic_report() instead.
  59   static void print_report(outputStream* out, size_t scale = 0, int flags = 0);
  60 
  61 };
  62 
  63 } // namespace metaspace
  64 
  65 #endif // SHARE_MEMORY_METASPACE_METASPACEREPORT_HPP