Created
March 27, 2020 23:56
-
-
Save matthewdowney/146ed6703d14622f46872a03e23d65e5 to your computer and use it in GitHub Desktop.
Clojure snippet to cause a JVM heap dump programmatically
This file contains hidden or 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
| (import 'java.lang.management.ManagementFactory) | |
| (import 'com.sun.management.HotSpotDiagnosticMXBean) | |
| (let [server (ManagementFactory/getPlatformMBeanServer) | |
| bean-name "com.sun.management:type=HotSpotDiagnostic" | |
| bean (ManagementFactory/newPlatformMXBeanProxy server bean-name HotSpotDiagnosticMXBean) | |
| live-objects-only? true] | |
| (.dumpHeap bean "heapdump.hprof" live-objects-only?)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment