I want to auto dump when out of memory happen using this code
HotSpotDiagnosticMXBean bean = ManagementFactory.newPlatformMXBeanProxy(
ManagementFactory.getPlatformMBeanServer(),
"com.sun.management:type=HotSpotDiagnostic",
HotSpotDiagnosticMXBean.class);
bean.setVMOption("HeapDumpOnOutOfMemoryError", "true");
bean.setVMOption("HeapDumpPath", fileName);
if i compile it using
mvn clean package
it work, but if i compile it using
mvn clean -Pnative native:compile
the “bean” (HotSpotDiagnosticMXBean) become null, why it become null?