Revision cc251391
Added by Andreas Kohlbecker about 8 years ago
src/main/java/eu/etaxonomy/cdm/server/JvmManager.java | ||
---|---|---|
24 | 24 |
*/ |
25 | 25 |
public class JvmManager { |
26 | 26 |
|
27 |
/** |
|
28 |
* |
|
29 |
*/ |
|
27 |
// Java 7 |
|
30 | 28 |
private static final String SUFFIX_PERM_GEN = "Perm Gen"; |
29 |
// Java > 8 |
|
30 |
private static final String SUFFIX_META = "Metaspace"; |
|
31 | 31 |
|
32 | 32 |
public static final Logger logger = Logger.getLogger(JvmManager.class); |
33 | 33 |
|
... | ... | |
35 | 35 |
return getMemoryPoolUsage(SUFFIX_PERM_GEN); |
36 | 36 |
} |
37 | 37 |
|
38 |
public static MemoryUsage getMetaSpaceUsage(){ |
|
39 |
return getMemoryPoolUsage(SUFFIX_META); |
|
40 |
} |
|
41 |
|
|
38 | 42 |
protected static MemoryUsage getMemoryPoolUsage(String nameSuffix) { |
39 | 43 |
List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans(); |
40 | 44 |
|
... | ... | |
42 | 46 |
if(memoryPoolMXBean.getName().endsWith(nameSuffix)){ |
43 | 47 |
logger.debug(memoryPoolMXBean.getName() |
44 | 48 |
+ ": init= " + memoryPoolMXBean.getUsage().getInit() |
45 |
+ ", used= "+memoryPoolMXBean.getUsage().getUsed() |
|
46 |
+ ", max= "+memoryPoolMXBean.getUsage().getMax() |
|
49 |
+ ", used= "+ memoryPoolMXBean.getUsage().getUsed()
|
|
50 |
+ ", max= "+ memoryPoolMXBean.getUsage().getMax()
|
|
47 | 51 |
+ ", committed= "+memoryPoolMXBean.getUsage().getCommitted()); |
48 | 52 |
return memoryPoolMXBean.getUsage(); |
49 | 53 |
} |
... | ... | |
75 | 79 |
return Runtime.getRuntime().availableProcessors(); |
76 | 80 |
} |
77 | 81 |
|
82 |
public static Integer getJvmVersion() { |
|
83 |
return Integer.parseInt(System.getProperty("java.version").split("\\.")[1]); |
|
84 |
// alternatively System.getProperty("java.specification.version"); |
|
85 |
} |
|
86 |
|
|
78 | 87 |
} |
Also available in: Unified diff
support for both memory models java 7 and java 8