如何识别 Windows 中的默认 Java 堆大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19028297/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 13:32:09  来源:igfitidea点击:

How to identify default Java heapsize in Windows

javamemorymemory-management

提问by vr3w3c9

Im running an eclipse application in my machine. I have two queries

我在我的机器上运行一个 eclipse 应用程序。我有两个疑问

  1. I would like to know how to check the default heap size that the jvm is using to run the application.I'm using a windows machine to run the java application. I tried to check the default heap size by the following way
  1. 我想知道如何检查 jvm 用于运行应用程序的默认堆大小。我正在使用 Windows 机器来运行 java 应用程序。我尝试通过以下方式检查默认堆大小

ControlPanel--->Programs--->JavaSetting--> JavaTab -->View Button ---> JavaRuntimeEnvironment settings window ---> Userstab --> Value under RuntimeParameters

ControlPanel--->Programs--->JavaSetting-->JavaTab-->查看按钮--->JavaRuntimeEnvironment设置窗口--->Userstab-->RuntimeParameters下的值

But in my system, there is no runtime parameters defined. Is there a command that I can execute via command prompt to check the default heap size in my machine.

但是在我的系统中,没有定义运行时参数。是否有我可以通过命令提示符执行的命令来检查我机器中的默认堆大小。

  1. How to increase the heap size parameter and run the eclipse plugin application from command prompt. For eg: To increase the heap size and execute the jar file we use the below command java -Xms64m -jar MyApp.jar. I would like to know how to set heap parameters and execute my java application which is an exefile. I tried to execute use the below command, but the command prompt doesn't recognize the command

    java -Xms512m iepsd.exe

  1. 如何增加堆大小参数并从命令提示符运行 eclipse 插件应用程序。例如:要增加堆大小并执行 jar 文件,我们使用以下命令 java -Xms64m -jar MyApp.jar。我想知道如何设置堆参数并执行作为exe文件的java 应用程序。我尝试使用以下命令执行,但命令提示符无法识别该命令

    java -Xms512m iepsd.exe

Where iepsd.exeis my java application.

iepsd.exe我的 Java 应用程序在哪里。

采纳答案by pburka

You can use -XX:+PrintFlagsFinalto print out a huge list of internal options to the JVM once all command line arguments and defaults have been processed. The -Xmsoption corresponds to InitialHeapSize, and the -Xmxoption corresponds to MaxHeapSize.

-XX:+PrintFlagsFinal处理完所有命令行参数和默认值后,您可以使用它向 JVM 打印出大量内部选项。该-Xms选项对应于InitialHeapSize和-Xmx选项对应MaxHeapSize。

To find the default maximum heap size that the JVM is using on Windows, run:

要查找 JVM 在 Windows 上使用的默认最大堆大小,请运行:

javaw -XX:+PrintFlagsFinal | find "MaxHeapSize"

To find the default initial heap size, run:

要查找默认初始堆大小,请运行:

javaw -XX:+PrintFlagsFinal | find "InitialHeapSize"

回答by Aniket Thakur

Use JConsole. It is shipped with the JDK. You will find it's executable in the corresponding bin directory.

使用 JConsole。它随 JDK 一起提供。您会在相应的 bin 目录中找到它的可执行文件。

回答by user1784741

To answer the below query of vr3w3c9

回答以下查询 vr3w3c9

Query raised by vr3w3c9: Hi, Thanks for the response. I tried to execute the above command javaw -XX:+PrintFlagsFinal | find "InitialHeapSize"in the command prompt, the value is not getting displayed. Im getting a popup message which says:

提问者vr3w3c9: 您好,感谢您的回复。我试图javaw -XX:+PrintFlagsFinal | find "InitialHeapSize"在命令提示符下执行上述命令,但没有显示该值。我收到一条弹出消息,上面写着:

could not create the java Virtual Machine – vr3w3c9 Sep 27 '13 at 4:54

无法创建 Java 虚拟机 – vr3w3c9 2013 年 9 月 27 日 4:54

Answer:In Windows machine, Please run/open the Command Prompt (Windows Command Processor) as Administratorand execute the command you have mentioned. you will get the result as shown below:

答:在 Windows 机器上,请以管理员身份运行/打开命令提示符(Windows 命令处理器)并执行您提到的命令。你会得到如下图所示的结果:

C:\windows\system32>javaw -XX:+PrintFlagsFinal | find "MaxHeapSize"

uintx MaxHeapSize                              := 2122317824      {product}

C:\windows\system32>javaw -XX:+PrintFlagsFinal | find "InitialHeapSize"

uintx InitialHeapSize                          := 132531136       {product}

Here, the unitof MaxHeapSize and InitialHeapSize is bytes.

这里MaxHeapSize 和 InitialHeapSize的单位bytes

回答by Amar Magar

try below command for detailed result

尝试以下命令以获取详细结果

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

result is

结果是

C:\Users\amar.magar>java -XX:+PrintFlagsFinal -version | findstr /i "HeapSize PermSize ThreadStackSize"
 intx CompilerThreadStackSize                   = 0                                   {pd product}
uintx ErgoHeapSizeLimit                         = 0                                   {product}
uintx HeapSizePerGCThread                       = 87241520                            {product}
uintx InitialHeapSize                          := 268435456                           {product}
uintx LargePageHeapSizeThreshold                = 134217728                           {product}
uintx MaxHeapSize                              := 4271898624                          {product}
 intx ThreadStackSize                           = 0                                   {pd product}
 intx VMThreadStackSize                         = 0                                   {pd product}

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

回答by levisaligue

Map JDK, usually in "C:\Program Files (x86)\Java\jdk1.8.xx.xx\bin\jconsole". Open jconsole app, you can now monitor and manage JVM.

映射JDK,通常在“C:\Program Files (x86)\Java\jdk1.8.xx.xx\bin\jconsole”。打开 jconsole 应用程序,您现在可以监控和管理 JVM。