How to request JVM garbage collection (not from code) when run from Windows command-line

前端 未结 4 1799
执笔经年
执笔经年 2020-12-31 05:41

how could I request Java garbage collection externally, starting the program from JAR (Windows BAT used)?

  • From the Java code I can do it with System.gc(
4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-31 06:18

    You can use jconsole to connect to a JVM that is running locally - This provides a "Perform GC" button on the GUI.

    You'll need to specify -Dcom.sun.management.jmxremote when you kick off your java process.

提交回复
热议问题