zgu@7074: /* zgu@7074: * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. zgu@7074: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. zgu@7074: * zgu@7074: * This code is free software; you can redistribute it and/or modify it zgu@7074: * under the terms of the GNU General Public License version 2 only, as zgu@7074: * published by the Free Software Foundation. zgu@7074: * zgu@7074: * This code is distributed in the hope that it will be useful, but WITHOUT zgu@7074: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or zgu@7074: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License zgu@7074: * version 2 for more details (a copy is included in the LICENSE file that zgu@7074: * accompanied this code). zgu@7074: * zgu@7074: * You should have received a copy of the GNU General Public License version zgu@7074: * 2 along with this work; if not, write to the Free Software Foundation, zgu@7074: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. zgu@7074: * zgu@7074: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA zgu@7074: * or visit www.oracle.com if you need additional information or have any zgu@7074: * questions. zgu@7074: * zgu@7074: */ zgu@7074: #include "precompiled.hpp" zgu@7074: #include "services/nmtCommon.hpp" zgu@7074: zgu@7074: const char* NMTUtil::_memory_type_names[] = { zgu@7074: "Java Heap", zgu@7074: "Class", zgu@7074: "Thread", zgu@7074: "Thread Stack", zgu@7074: "Code", zgu@7074: "GC", zgu@7074: "Compiler", zgu@7074: "Internal", zgu@7074: "Other", zgu@7074: "Symbol", zgu@7074: "Native Memory Tracking", zgu@7074: "Shared class space", zgu@7074: "Arena Chunk", zgu@7074: "Test", zgu@7074: "Tracing", zgu@7074: "Unknown" zgu@7074: }; zgu@7074: zgu@7074: zgu@7074: const char* NMTUtil::scale_name(size_t scale) { zgu@7074: switch(scale) { zgu@7074: case K: return "KB"; zgu@7074: case M: return "MB"; zgu@7074: case G: return "GB"; zgu@7074: } zgu@7074: ShouldNotReachHere(); zgu@7074: return NULL; zgu@7074: } zgu@7074: zgu@7074: size_t NMTUtil::scale_from_name(const char* scale) { zgu@7074: assert(scale != NULL, "Null pointer check"); zgu@7074: if (strncmp(scale, "KB", 2) == 0 || zgu@7074: strncmp(scale, "kb", 2) == 0) { zgu@7074: return K; zgu@7074: } else if (strncmp(scale, "MB", 2) == 0 || zgu@7074: strncmp(scale, "mb", 2) == 0) { zgu@7074: return M; zgu@7074: } else if (strncmp(scale, "GB", 2) == 0 || zgu@7074: strncmp(scale, "gb", 2) == 0) { zgu@7074: return G; zgu@7074: } else { zgu@7074: return 0; // Invalid value zgu@7074: } zgu@7074: return K; zgu@7074: } zgu@7074: