-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGCMxBeanExample.java
44 lines (35 loc) · 1022 Bytes
/
GCMxBeanExample.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
/**
*
*/
package com.ankit.gcexamples;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.util.List;
/**
*Mx Beans to get garbage Collection information
*This program can be run with diff VM arguments to control GC.
*-XX:+UseConcMarkSweepGC as vm args
* @author ankitkumar
*
*/
public class GCMxBeanExample {
/**
* @param args
*/
public static void main(String[] args) {
GCMxBeanExample.workingMXBean();
}
public static void workingMXBean(){
List<GarbageCollectorMXBean> list=ManagementFactory.getGarbageCollectorMXBeans();
list.forEach((bean) ->{
System.out.println("Name..." + bean.getName());
System.out.println("No. of Collections.."+bean.getCollectionCount());
System.out.println("Collection Time.."+bean.getCollectionTime()+"...ms");
System.out.println("Pool Names...");
for(String poolName:bean.getMemoryPoolNames()){
System.out.println("\t" +poolName);
}
System.out.println();
});
}
}