How to Increase JVM / Java Heap Size,Increasing JVM / Java Heap Size Tutorial

Java programs executes in JVM uses Heap of memory to manage the data. If your Java program requires a large amount of memory, it is possible that the virtual machine will begin to throw OutOfMemoryError instances when attempting to instantiate an object. The default heap size if 1 MB and can increase as much as 16 MB.

It is possible to increase heap size allocated by the Java Virtual Machine (JVM) by using command line options.
Following are few options available to change Heap Size.

-Xms<size>        set initial Java heap size
-Xmx<size>        set maximum Java heap size
-Xss<size>        set java thread stack size
 
Also we can set the Minimum and Maximum Heap size
 
java -Xms64m -Xmx256m MyProgram

No comments:

Post a Comment

Please Provide your feedback here