Increase heap size in Java
You can increase to 2GB
on a 32
bit system. If you're on a 64 bit system you can go higher. No need to worry if you've chosen incorrectly, if you ask for 5g on a 32 bit system java will complain about an invalid value and quit.
As others have posted, use the cmd-line flags - e.g.
java -Xmx6g myprogram
You can get a full list (or a nearly full list, anyway) by typing java -X.
It is possible to increase heap size allocated by the JVM by using command line optionsHere we have 3 options
-Xms<size> set initial Java heap size-Xmx<size> set maximum Java heap size-Xss<size> set java thread stack sizejava -Xms16m -Xmx64m ClassName
In the above line we can set minimum heap to 16mb and maximum heap 64mb
On a 32-bit JVM, the largest heap size you can theoretically set is 4gb. To use a larger heap size, you need to use a 64-bit JVM. Try the following:
java -Xmx6144M -d64
The -d64 flag is important as this tells the JVM to run in 64-bit mode.