Generate Java heap dump programmatically on AIX

42 Views Asked by At

I'm trying to find the source of a memory leak in a Java application running in Java 8 on AIX. I want to programmatically generate a heap dump from within the Java app, when a certain condition occurs.

Multiple SO answers suggest this approach, which works great on my Windows laptop:

MBeanServer server = ManagementFactory.getPlatformMBeanServer();
HotSpotDiagnosticMXBean mxBean = ManagementFactory.newPlatformMXBeanProxy(
        server, "com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class);
mxBean.dumpHeap("heap_" + System.currentTimeMillis + ".hprof", false);

However, this does not work in an AIX environment as com.sun.management is not available there. So I think I need to find the AIX equivalent to the Sun arguments to the ManagementFactory.newPlatformMXBeanProxy method: "com.sun.management:type=HotSpotDiagnostic" and HotSpotDiagnosticMXBean.class. I've not been able to find the mxBeanName and MXBean interface for this environment. Does anyone know what is needed here?

[The memory leak accumulates over several days and my customer reports that it leads to slow processing and various timeouts. The timing of it is unpredictable and the customer is unaware of the leak until it's a serious problem. They have asked for the heap dump to be generated programmatically. Requesting it from the console is not practical for them.]

0

There are 0 best solutions below