I am making my Java application and I am having a problem with my heap size. Can anyone tell how to increase the heap size please.
2 Answers
You can make use of below parameters to configure size as per your need.
-Xms<size> set initial Java heap size
-Xmx<size> set maximum Java heap size
-Xss<size> set java thread stack size
like , java -Xmx256m Main.java

- 8,218
- 4
- 39
- 58
It all depends on the operation system you are using. The table below shows the base line for the various operating systems. The maximum heap memory you can allocate can also be seen below.
Redhat Linux 32 bit: 2 GB Redhat Linux 64 bit: 3 GB Windows 98/2000/NT/Me/XP: 2 GB Solaris x86 (32 bit): 4 GB Solaris 32 bit: 4 GB Solaris 64 bit: Terabytes
The Maximum heap space is always smaller than maximum address space per process, this is because the process also needs space for stack, libraries, and so on.
You can control the heap size using the following JVM Parameters [Source: Oracle] ;
• -Xmsvalue
• -Xmxvalue
• -XX:MinHeapFreeRatio=minimum
• -XX:MaxHeapFreeRatio=maximum
• -XX:NewRatio=ratio
• -XX:NewSize=size
• -XX:MaxNewSize=size
• -XX:+AggressiveHeap
Hope this helps, let me know if you would like any further help :) .

- 763
- 3
- 10
- 18