Created
March 19, 2019 19:41
-
-
Save jerolba/a1baa6279d0ea704f45e5288fc4363f5 to your computer and use it in GitHub Desktop.
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
public void memoryHistogram() { | |
String name = ManagementFactory.getRuntimeMXBean().getName(); | |
String PID = name.substring(0, name.indexOf("@")); | |
Process p = Runtime.getRuntime().exec("jcmd " + PID + " GC.class_histogram"); | |
try (BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()))) { | |
input.lines().forEach(System.out::println); | |
} | |
} | |
public void memoryAnalysis(){ | |
memoryHistogram(); | |
Object instance = codeThatCreatesComplexDataStructure(); | |
memoryHistogram(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment