< prev index next >

src/hotspot/share/memory/metaspace/metaspaceDCmd.cpp

Print this page
rev 50188 : [mq]: 8203219-VM.metaspace-show-loaded-classes
   1 /*
   2  * Copyright (c) 2018, 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 #include "precompiled.hpp"
  25 #include "memory/metaspace.hpp"
  26 #include "memory/metaspace/metaspaceDCmd.hpp"
  27 #include "memory/resourceArea.hpp"
  28 #include "services/diagnosticCommand.hpp"
  29 #include "services/nmtCommon.hpp"
  30 
  31 namespace metaspace {
  32 
  33 MetaspaceDCmd::MetaspaceDCmd(outputStream* output, bool heap)
  34   : DCmdWithParser(output, heap)
  35   , _basic("basic", "Prints a basic summary (does not need a safepoint).", "BOOLEAN", false, "false")
  36   , _show_loaders("show-loaders", "Shows usage by class loader.", "BOOLEAN", false, "false")

  37   , _by_chunktype("by-chunktype", "Break down numbers by chunk type.", "BOOLEAN", false, "false")
  38   , _by_spacetype("by-spacetype", "Break down numbers by loader type.", "BOOLEAN", false, "false")
  39   , _show_vslist("vslist", "Shows details about the underlying virtual space.", "BOOLEAN", false, "false")
  40   , _show_vsmap("vsmap", "Shows chunk composition of the underlying virtual spaces", "BOOLEAN", false, "false")
  41   , _scale("scale", "Memory usage in which to scale. Valid values are: 1, KB, MB or GB (fixed scale) "
  42            "or \"dynamic\" for a dynamically choosen scale.",
  43      "STRING", false, "dynamic")
  44 {
  45   _dcmdparser.add_dcmd_option(&_basic);
  46   _dcmdparser.add_dcmd_option(&_show_loaders);

  47   _dcmdparser.add_dcmd_option(&_by_chunktype);
  48   _dcmdparser.add_dcmd_option(&_by_spacetype);
  49   _dcmdparser.add_dcmd_option(&_show_vslist);
  50   _dcmdparser.add_dcmd_option(&_show_vsmap);
  51   _dcmdparser.add_dcmd_option(&_scale);
  52 }
  53 
  54 int MetaspaceDCmd::num_arguments() {
  55   ResourceMark rm;
  56   MetaspaceDCmd* dcmd = new MetaspaceDCmd(NULL, false);
  57   if (dcmd != NULL) {
  58     DCmdMark mark(dcmd);
  59     return dcmd->_dcmdparser.num_arguments();
  60   } else {
  61     return 0;
  62   }
  63 }
  64 
  65 void MetaspaceDCmd::execute(DCmdSource source, TRAPS) {
  66   // Parse scale value.


  70     if (strcasecmp("dynamic", scale_value) == 0) {
  71       scale = 0;
  72     } else {
  73       scale = NMT_ONLY(NMTUtil::scale_from_name(scale_value)) NOT_NMT(0);
  74       if (scale == 0) {
  75         output()->print_cr("Invalid scale: \"%s\". Will use dynamic scaling.", scale_value);
  76       }
  77     }
  78   }
  79   if (_basic.value() == true) {
  80     if (_show_loaders.value() || _by_chunktype.value() || _by_spacetype.value() ||
  81         _show_vslist.value() || _show_vsmap.value()) {
  82       // Basic mode. Just print essentials. Does not need to be at a safepoint.
  83       output()->print_cr("In basic mode, additional arguments are ignored.");
  84     }
  85     MetaspaceUtils::print_basic_report(output(), scale);
  86   } else {
  87     // Full mode. Requires safepoint.
  88     int flags = 0;
  89     if (_show_loaders.value())         flags |= MetaspaceUtils::rf_show_loaders;

  90     if (_by_chunktype.value())         flags |= MetaspaceUtils::rf_break_down_by_chunktype;
  91     if (_by_spacetype.value())         flags |= MetaspaceUtils::rf_break_down_by_spacetype;
  92     if (_show_vslist.value())          flags |= MetaspaceUtils::rf_show_vslist;
  93     if (_show_vsmap.value())           flags |= MetaspaceUtils::rf_show_vsmap;
  94     VM_PrintMetadata op(output(), scale, flags);
  95     VMThread::execute(&op);
  96   }
  97 }
  98 
  99 } // namespace metaspace
 100 
   1 /*
   2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2018, SAP and/or its affiliates.
   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 #include "precompiled.hpp"
  26 #include "memory/metaspace.hpp"
  27 #include "memory/metaspace/metaspaceDCmd.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "services/diagnosticCommand.hpp"
  30 #include "services/nmtCommon.hpp"
  31 
  32 namespace metaspace {
  33 
  34 MetaspaceDCmd::MetaspaceDCmd(outputStream* output, bool heap)
  35   : DCmdWithParser(output, heap)
  36   , _basic("basic", "Prints a basic summary (does not need a safepoint).", "BOOLEAN", false, "false")
  37   , _show_loaders("show-loaders", "Shows usage by class loader.", "BOOLEAN", false, "false")
  38   , _show_classes("show-classes", "If show-loaders is set, shows loaded classes for each loader.", "BOOLEAN", false, "false")
  39   , _by_chunktype("by-chunktype", "Break down numbers by chunk type.", "BOOLEAN", false, "false")
  40   , _by_spacetype("by-spacetype", "Break down numbers by loader type.", "BOOLEAN", false, "false")
  41   , _show_vslist("vslist", "Shows details about the underlying virtual space.", "BOOLEAN", false, "false")
  42   , _show_vsmap("vsmap", "Shows chunk composition of the underlying virtual spaces", "BOOLEAN", false, "false")
  43   , _scale("scale", "Memory usage in which to scale. Valid values are: 1, KB, MB or GB (fixed scale) "
  44            "or \"dynamic\" for a dynamically choosen scale.",
  45      "STRING", false, "dynamic")
  46 {
  47   _dcmdparser.add_dcmd_option(&_basic);
  48   _dcmdparser.add_dcmd_option(&_show_loaders);
  49   _dcmdparser.add_dcmd_option(&_show_classes);
  50   _dcmdparser.add_dcmd_option(&_by_chunktype);
  51   _dcmdparser.add_dcmd_option(&_by_spacetype);
  52   _dcmdparser.add_dcmd_option(&_show_vslist);
  53   _dcmdparser.add_dcmd_option(&_show_vsmap);
  54   _dcmdparser.add_dcmd_option(&_scale);
  55 }
  56 
  57 int MetaspaceDCmd::num_arguments() {
  58   ResourceMark rm;
  59   MetaspaceDCmd* dcmd = new MetaspaceDCmd(NULL, false);
  60   if (dcmd != NULL) {
  61     DCmdMark mark(dcmd);
  62     return dcmd->_dcmdparser.num_arguments();
  63   } else {
  64     return 0;
  65   }
  66 }
  67 
  68 void MetaspaceDCmd::execute(DCmdSource source, TRAPS) {
  69   // Parse scale value.


  73     if (strcasecmp("dynamic", scale_value) == 0) {
  74       scale = 0;
  75     } else {
  76       scale = NMT_ONLY(NMTUtil::scale_from_name(scale_value)) NOT_NMT(0);
  77       if (scale == 0) {
  78         output()->print_cr("Invalid scale: \"%s\". Will use dynamic scaling.", scale_value);
  79       }
  80     }
  81   }
  82   if (_basic.value() == true) {
  83     if (_show_loaders.value() || _by_chunktype.value() || _by_spacetype.value() ||
  84         _show_vslist.value() || _show_vsmap.value()) {
  85       // Basic mode. Just print essentials. Does not need to be at a safepoint.
  86       output()->print_cr("In basic mode, additional arguments are ignored.");
  87     }
  88     MetaspaceUtils::print_basic_report(output(), scale);
  89   } else {
  90     // Full mode. Requires safepoint.
  91     int flags = 0;
  92     if (_show_loaders.value())         flags |= MetaspaceUtils::rf_show_loaders;
  93     if (_show_classes.value())         flags |= MetaspaceUtils::rf_show_classes;
  94     if (_by_chunktype.value())         flags |= MetaspaceUtils::rf_break_down_by_chunktype;
  95     if (_by_spacetype.value())         flags |= MetaspaceUtils::rf_break_down_by_spacetype;
  96     if (_show_vslist.value())          flags |= MetaspaceUtils::rf_show_vslist;
  97     if (_show_vsmap.value())           flags |= MetaspaceUtils::rf_show_vsmap;
  98     VM_PrintMetadata op(output(), scale, flags);
  99     VMThread::execute(&op);
 100   }
 101 }
 102 
 103 } // namespace metaspace
 104 
< prev index next >