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 "services/nmtCommon.hpp"
26
27 const char* NMTUtil::_memory_type_names[] = {
28 "Java Heap",
29 "Class",
30 "Thread",
31 "Thread Stack",
32 "Code",
33 "GC",
34 "Compiler",
35 "Internal",
36 "Other",
37 "Symbol",
38 "Native Memory Tracking",
39 "Shared class space",
40 "Arena Chunk",
41 "Test",
42 "Tracing",
43 "Logging",
44 "Arguments",
45 "Module",
46 "Unknown"
47 };
48
49
50 const char* NMTUtil::scale_name(size_t scale) {
51 switch(scale) {
52 case K: return "KB";
53 case M: return "MB";
54 case G: return "GB";
55 }
56 ShouldNotReachHere();
57 return NULL;
58 }
59
60 size_t NMTUtil::scale_from_name(const char* scale) {
61 assert(scale != NULL, "Null pointer check");
62 if (strncmp(scale, "KB", 2) == 0 ||
63 strncmp(scale, "kb", 2) == 0) {
64 return K;
65 } else if (strncmp(scale, "MB", 2) == 0 ||
66 strncmp(scale, "mb", 2) == 0) {
67 return M;
68 } else if (strncmp(scale, "GB", 2) == 0 ||
69 strncmp(scale, "gb", 2) == 0) {
70 return G;
71 } else {
72 return 0; // Invalid value
73 }
74 return K;
75 }
76
|
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 "services/nmtCommon.hpp"
26 #include "utilities/globalDefinitions.hpp"
27
28 const char* NMTUtil::_memory_type_names[] = {
29 "Java Heap",
30 "Class",
31 "Thread",
32 "Thread Stack",
33 "Code",
34 "GC",
35 "Compiler",
36 "Internal",
37 "Other",
38 "Symbol",
39 "Native Memory Tracking",
40 "Shared class space",
41 "Arena Chunk",
42 "Test",
43 "Tracing",
44 "Logging",
45 "Arguments",
46 "Module",
47 "Unknown"
48 };
49
50
51 const char* NMTUtil::scale_name(size_t scale) {
52 switch(scale) {
53 case K: return "KB";
54 case M: return "MB";
55 case G: return "GB";
56 }
57 ShouldNotReachHere();
58 return NULL;
59 }
60
61 size_t NMTUtil::scale_from_name(const char* scale) {
62 assert(scale != NULL, "Null pointer check");
63 if (strcasecmp(scale, "1") == 0 || strcasecmp(scale, "b") == 0) {
64 return 1;
65 } else if (strcasecmp(scale, "kb") == 0 || strcasecmp(scale, "k") == 0) {
66 return K;
67 } else if (strcasecmp(scale, "mb") == 0 || strcasecmp(scale, "m") == 0) {
68 return M;
69 } else if (strcasecmp(scale, "gb") == 0 || strcasecmp(scale, "g") == 0) {
70 return G;
71 } else {
72 return 0; // Invalid value
73 }
74 return K;
75 }
76
|