There a lot of JVM arguments that affect the JVM\'s memory usage like -Xms, -Xmx, -Xns, -XX:MaxPermSize...
Read JVM options explained. Here're excerpts from it:
java.lang.OutOfMemoryError: Java heap space errors you should increase -Xmx value.-XX:PermSize and -XX:MaxPermSize do not need to be adjusted but if you are seeing java.lang.OutOfMemoryError: PermGen space events often you can increase these values.-XX:MaxJavaStackTraceDepth - This specifies how many entries a stack trace for a thrown error or exception can have before a StackOverflowError is thrown. So if you are dealing with huge stack traces you can use this option to increase the allowed entriers before overflow.