| 1 | /* |
| 2 | * Copyright (c) 2012, 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_SERVICES_NMTDCMD_HPP |
| 26 | #define SHARE_SERVICES_NMTDCMD_HPP |
| 27 | |
| 28 | #if INCLUDE_NMT |
| 29 | |
| 30 | #include "services/diagnosticArgument.hpp" |
| 31 | #include "services/diagnosticFramework.hpp" |
| 32 | #include "services/memBaseline.hpp" |
| 33 | #include "services/mallocTracker.hpp" |
| 34 | |
| 35 | /** |
| 36 | * Native memory tracking DCmd implementation |
| 37 | */ |
| 38 | class NMTDCmd: public DCmdWithParser { |
| 39 | protected: |
| 40 | DCmdArgument<bool> _summary; |
| 41 | DCmdArgument<bool> _detail; |
| 42 | DCmdArgument<bool> _baseline; |
| 43 | DCmdArgument<bool> _summary_diff; |
| 44 | DCmdArgument<bool> _detail_diff; |
| 45 | DCmdArgument<bool> _shutdown; |
| 46 | DCmdArgument<bool> _statistics; |
| 47 | DCmdArgument<char*> _scale; |
| 48 | |
| 49 | public: |
| 50 | NMTDCmd(outputStream* output, bool heap); |
| 51 | static const char* name() { return "VM.native_memory" ; } |
| 52 | static const char* description() { |
| 53 | return "Print native memory usage" ; |
| 54 | } |
| 55 | static const char* impact() { |
| 56 | return "Medium" ; |
| 57 | } |
| 58 | static const JavaPermission permission() { |
| 59 | JavaPermission p = {"java.lang.management.ManagementPermission" , |
| 60 | "monitor" , NULL}; |
| 61 | return p; |
| 62 | } |
| 63 | static int num_arguments(); |
| 64 | virtual void execute(DCmdSource source, TRAPS); |
| 65 | |
| 66 | private: |
| 67 | void report(bool summaryOnly, size_t scale); |
| 68 | void report_diff(bool summaryOnly, size_t scale); |
| 69 | |
| 70 | size_t get_scale(const char* scale) const; |
| 71 | |
| 72 | // check if NMT running at detail tracking level |
| 73 | bool check_detail_tracking_level(outputStream* out); |
| 74 | }; |
| 75 | |
| 76 | #endif // INCLUDE_NMT |
| 77 | |
| 78 | #endif // SHARE_SERVICES_NMTDCMD_HPP |
| 79 | |