Skip to content

Instantly share code, notes, and snippets.

@michaljemala
Created May 19, 2015 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save michaljemala/6db3c67f4b34231895e3 to your computer and use it in GitHub Desktop.
Save michaljemala/6db3c67f4b34231895e3 to your computer and use it in GitHub Desktop.
A sample Native Memory Tracking dump
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