0

Is it possible to execute 'jmap' at different spots inside my java-programm to generate dump files. I guess one must get the own process ID and than execute the command via Runtime().exec() or similar. Didn't succeed though.

Chris

trincot
  • 317,000
  • 35
  • 244
  • 286
Christian
  • 1,308
  • 3
  • 14
  • 24

1 Answers1

3

Try:

String name = ManagementFactory.getRuntimeMXBean().getName();
String[] str = name.split("@");
Runtime.getRuntime().exec("jmap -dump:file=YOURFILENAME " + str[0]);
michiruf
  • 413
  • 1
  • 7
  • 13