Java堆大小值不会发生变化

时间:2021-01-25 17:19:42

I have set java heap size using below command in a spring boot application.

我在spring启动应用程序中使用下面的命令设置了java堆大小。

java -Xms512m -Xmx1024m -jar test.jar

But when I examine the sizes again using below command I dont see the values change?

但是当我使用下面的命令再次检查尺寸时,我看不到值的变化?

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

1 个解决方案

#1


2  

You are not examining heap size again. The second command starts a separate Java process and will therefore start with default heap size (since you have not provided Xms/Xmx to it). That second process exits as soon as it prints the version.

您没有再次检查堆大小。第二个命令启动一个单独的Java进程,因此将以默认堆大小开始(因为您没有向它提供Xms / Xmx)。第二个进程在打印版本后立即退出。

To check the heap size of an already running Java process you can do one of the following:

要检查已运行的Java进程的堆大小,可以执行以下操作之一:

  • connect to the running JVM using profiler, JMX,
  • 使用profiler,JMX连接到正在运行的JVM,

  • In the running program, invoke Runtime.getRuntime().totalMemory/maxMemory or
  • 在正在运行的程序中,调用Runtime.getRuntime()。totalMemory / maxMemory或

  • use the jcmd or jstat tools (both are part of the JDK).
  • 使用jcmd或jstat工具(都是JDK的一部分)。

#1


2  

You are not examining heap size again. The second command starts a separate Java process and will therefore start with default heap size (since you have not provided Xms/Xmx to it). That second process exits as soon as it prints the version.

您没有再次检查堆大小。第二个命令启动一个单独的Java进程,因此将以默认堆大小开始(因为您没有向它提供Xms / Xmx)。第二个进程在打印版本后立即退出。

To check the heap size of an already running Java process you can do one of the following:

要检查已运行的Java进程的堆大小,可以执行以下操作之一:

  • connect to the running JVM using profiler, JMX,
  • 使用profiler,JMX连接到正在运行的JVM,

  • In the running program, invoke Runtime.getRuntime().totalMemory/maxMemory or
  • 在正在运行的程序中,调用Runtime.getRuntime()。totalMemory / maxMemory或

  • use the jcmd or jstat tools (both are part of the JDK).
  • 使用jcmd或jstat工具(都是JDK的一部分)。