Getting the parameters of a running JVM

前端 未结 12 553
栀梦
栀梦 2020-12-04 05:43

Is there a way to get the parameters of a running JVM? Is there a command line tool like jstat which takes as input the pid of the JVM and returns its starting parameters? I

相关标签:
12条回答
  • 2020-12-04 06:07

    If you are interested in getting the JVM parameters of a running java process, then just do kill -3 java-pid. You will get a core dump file in which you can find the jvm parameters used while launching the java application.

    0 讨论(0)
  • 2020-12-04 06:09

    You can use the JConsole command (or any other JMX client) to access that information.

    0 讨论(0)
  • 2020-12-04 06:13

    If you can do this in java, try:

    RuntimeMXBean

    ManagementFactory

    Example:

    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
    List<String> jvmArgs = runtimeMXBean.getInputArguments();
    for (String arg : jvmArgs) {
        System.out.println(arg);
    }
    
    0 讨论(0)
  • 2020-12-04 06:21

    This technique applies for any java application running local or remote.

    1. Start your java application.
    2. Run JVisualVM found in you JDK (such as C:\Program Files\Java\jdk1.8.0_05\bin\jvisualvm.exe).
    3. When this useful tool starts look at the list of running java application under the "Local" tree node.
    4. Double click [your application] (pid [n]).
    5. On the right side there will be inspection contents in tab for the application. In the middle of the Overview tab you will see the JVM arguments for the application.

    jvisualvm can be found in any JDK since JDK 6 Update 7. Video tutorial on jvisualvm is here.

    0 讨论(0)
  • 2020-12-04 06:25

    JConsole can do it. Also you can use a powerful jvisualVM tool, which also is included in JDK since 1.6.0.8.

    0 讨论(0)
  • 2020-12-04 06:27

    On Linux:

    java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'
    

    On Mac OSX:

    java -XX:+PrintFlagsFinal -version | grep -iE 'heapsize|permsize|threadstacksize'
    

    On Windows:

    C:\>java -XX:+PrintFlagsFinal -version | findstr /i "HeapSize PermSize ThreadStackSize"
    

    Source: https://www.mkyong.com/java/find-out-your-java-heap-memory-size/

    0 讨论(0)
提交回复
热议问题