Skip to content

Instantly share code, notes, and snippets.

@ashkrit
Created August 18, 2019 04:54
Show Gist options
  • Save ashkrit/1922b5e9a65d52bce9bb9b0049f80af8 to your computer and use it in GitHub Desktop.
Save ashkrit/1922b5e9a65d52bce9bb9b0049f80af8 to your computer and use it in GitHub Desktop.
public class VerifyCurrentGC {
public static void main(String... args) {
var gcBeans = ManagementFactory.getGarbageCollectorMXBeans();
gcBeans.stream().forEach(gc -> {
out.println(format("GC Name : %s", gc.getName()));
var poolNames = gc.getMemoryPoolNames();
if (poolNames != null) {
List.of(poolNames).forEach(pool ->
out.println(format("Pool name %s", pool)));
} else {
out.println("No memory pools for " + gc.getName());
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment