Solved - Java Specify Heap Size OpenJDK11 | The FreeBSD Forums
Increase heap size in Java - Stack Overflow
bash - How do I set the default maximum Java heap size? - Raspberry Pi Stack Exchange
Java process consuming more memory than assigned Max heap
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 these command line options:
-Xms<size> set initial Java heap size
-Xmx<size> set maximum Java heap size
-Xss<size> set java thread stack size
In the following example, minimum heap size is set to 16mb, and the maximum to 64mb:
java -Xms16m -Xmx64m ClassName
The maximum heap size is not the maximum amount of memory the JVM will use, but the heap size is what Xmx actually sets.
Regarding settings, it seems there maybe issues with JAVA_OPTIONS, a more bulletproof method would be to add this to .bashrc:
alias java='java -Xms1024m'
Or, since environment variables are interpolated in an alias:
alias java='java $MY_JAVA_OPTS'
export MY_JAVA_OPTS="-Xms1024m"
This gives you some flexibility if you want to add or override $MY_JAVA_OPTS for some session:
MY_JAVA_OPTS="$MY_JAVA_OPTS -Xprof -Xdiag"
Solved this by adding export _JAVA_OPTIONS=-Xmx1024m to /etc/profile file.