Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify default Java heapsize in Windows

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

  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

ControlPanel--->Programs--->JavaSetting--> JavaTab -->View Button ---> JavaRuntimeEnvironment settings window ---> Userstab --> Value under 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 exe file. I tried to execute use the below command, but the command prompt doesn't recognize the command

    java -Xms512m iepsd.exe

Where iepsd.exe is my java application.

like image 492
vr3w3c9 Avatar asked Sep 26 '13 12:09

vr3w3c9


People also ask

What is the default heap size for Java?

The Java™ virtual machine (JVM) heap size setting directly relates to how many server instances can be started within a dynamic cluster on a specific node. You might need to modify the JVM heap size setting based on your environment configuration. The default value is 256 MB.

How do I monitor Java heap size in Windows?

The easy way to monitor Heap usage is by using a commercial APM (Application Performance management tool) such as CA Wily APM, AppDynamics, New Relic, Riverbed, etc. APM tools not only monitor the heap usage, but you can also configure the tool to Alert you when Heap usage is not normal.

Where is Java heap size set?

Under the Configuration Tasks section, select Edit Java Settings. Click the JVM Settings tab to display the JVM options. Edit the -Xmx256m option. This option sets the JVM heap size.


4 Answers

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

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

javaw -XX:+PrintFlagsFinal | find "MaxHeapSize"

To find the default initial heap size, run:

javaw -XX:+PrintFlagsFinal | find "InitialHeapSize"
like image 97
pburka Avatar answered Oct 29 '22 21:10

pburka


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)
like image 34
Amar Magar Avatar answered Oct 29 '22 23:10

Amar Magar


To answer the below query of 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:

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

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

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 unit of MaxHeapSize and InitialHeapSize is bytes.

like image 4
user1784741 Avatar answered Oct 29 '22 23:10

user1784741


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

like image 1
Aniket Thakur Avatar answered Oct 29 '22 21:10

Aniket Thakur