If you find that your Java application is running our of heap space and you don’t have a memory leak, you can give the JMV more memory. This is very simple to do by starting your java application with the following argument.
java -Xmx6g myprogram
You have three options for increasing size
-Xms<size> set initial Java heap size -Xmx<size> set maximum Java heap size -Xss<size> set java thread stack size java -Xms16m -Xmx64m ClassName