forked from mcabaj/nmt-metrics
-
Notifications
You must be signed in to change notification settings - Fork 1
/
NativeMemoryTrackingType.java
81 lines (51 loc) · 1.66 KB
/
NativeMemoryTrackingType.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.marekcabaj.nmt.bean;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
// from src/hotspot/share/services/nmtCommon.cpp
public enum NativeMemoryTrackingType {
// total
TOTAL("Total"),
JAVA_HEAP("Java Heap"),
CLASS("Class"),
THREAD("Thread"),
THREAD_STACK("Thread Stack"),
CODE("Code"),
GC("GC"),
COMPILER("Compiler"),
INTERNAL("Internal"),
OTHER("Other"),
SYMBOL("Symbol"),
NMT("Native Memory Tracking"),
SHARED_CLASS_SPACE("Shared class space"),
ARENA_CHUNK("Arena Chunk"),
TEST("Test"),
TRACING("Tracing"),
LOGGING("Logging"),
ARGUMENTS("Arguments"),
MODULE("Module"),
UNKNOWN("Unknown");
private String label;
private String category;
private NativeMemoryTrackingType(String label) {
this.label = label;
this.category = label.toLowerCase().replace(' ', '.');
}
public String getLabel() {
return label;
}
public String getCategory() {
return category;
}
private static final LoadingCache<String, NativeMemoryTrackingType> BY_LABEL = Caffeine.newBuilder().build(NativeMemoryTrackingType::findByName);
protected static NativeMemoryTrackingType findByName(String label) {
for (NativeMemoryTrackingType nmtType : values()) {
if (nmtType.getLabel().equals(label)) {
return nmtType;
}
}
throw new IllegalArgumentException("No enum constant for label " + label);
}
public static NativeMemoryTrackingType getByLabel(String label) {
return BY_LABEL.get(label);
}
}