* expanded appsettings to include java specific stuff * added java indexer as separate project that can be build via its build script * added dependencies for java indexer to the setup folder * added license files for these dependencies. * added sample project for java. this is just to test java on other machines and can be removed again in the future. * the java parser test suite is currently uncommented because java is not running on every machine. * added some more node types * removed TokenComponentAccess::AccessType and replaced all its usages by using AccessKind * moved access components from edges to nodes * using recordReference of ParserClient for java * removed recording access specifier of inheritance edges. * added styles for new node types
62 lines
2.0 KiB
Java
62 lines
2.0 KiB
Java
package io.coati;
|
|
|
|
import javax.management.MBeanServer;
|
|
import java.lang.management.ManagementFactory;
|
|
import com.sun.management.HotSpotDiagnosticMXBean;
|
|
|
|
public class HeapDumper {
|
|
// This is the name of the HotSpot Diagnostic MBean
|
|
private static final String HOTSPOT_BEAN_NAME =
|
|
"com.sun.management:type=HotSpotDiagnostic";
|
|
|
|
// field to store the hotspot diagnostic MBean
|
|
private static volatile HotSpotDiagnosticMXBean hotspotMBean;
|
|
|
|
/*\*
|
|
\* Call this method from your application whenever you
|
|
\* want to dump the heap snapshot into a file.
|
|
\*
|
|
\* @param fileName name of the heap dump file
|
|
\* @param live flag that tells whether to dump
|
|
\* only the live objects
|
|
\*/
|
|
static void dumpHeap(String fileName, boolean live) {
|
|
// initialize hotspot diagnostic MBean
|
|
initHotspotMBean();
|
|
try {
|
|
hotspotMBean.dumpHeap(fileName, live);
|
|
} catch (RuntimeException re) {
|
|
throw re;
|
|
} catch (Exception exp) {
|
|
throw new RuntimeException(exp);
|
|
}
|
|
}
|
|
|
|
// initialize the hotspot diagnostic MBean field
|
|
private static void initHotspotMBean() {
|
|
if (hotspotMBean == null) {
|
|
synchronized (HeapDumper.class) {
|
|
if (hotspotMBean == null) {
|
|
hotspotMBean = getHotspotMBean();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// get the hotspot diagnostic MBean from the
|
|
// platform MBean server
|
|
private static HotSpotDiagnosticMXBean getHotspotMBean() {
|
|
try {
|
|
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
|
|
HotSpotDiagnosticMXBean bean =
|
|
ManagementFactory.newPlatformMXBeanProxy(server,
|
|
HOTSPOT_BEAN_NAME, HotSpotDiagnosticMXBean.class);
|
|
return bean;
|
|
} catch (RuntimeException re) {
|
|
throw re;
|
|
} catch (Exception exp) {
|
|
throw new RuntimeException(exp);
|
|
}
|
|
}
|
|
}
|