Created
May 19, 2015 09:15
-
-
Save michaljemala/6db3c67f4b34231895e3 to your computer and use it in GitHub Desktop.
A sample Native Memory Tracking dump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example; | |
import java.lang.management.ManagementFactory; | |
import javax.management.MBeanServer; | |
import javax.management.ObjectName; | |
public class NativeDumper { | |
public static String dumpNative() { | |
MBeanServer server = ManagementFactory.getPlatformMBeanServer(); | |
try { | |
Object out = server.invoke(new ObjectName( | |
"com.sun.management:type=DiagnosticCommand"), | |
"vmNativeMemory", | |
new Object[] { new String[] { "summary" } }, | |
new String[] { String[].class.getName() }); | |
return (String) out; | |
} catch (RuntimeException e) { | |
throw e; | |
} catch (Exception e) { | |
throw new RuntimeException(e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment