You receive this message when compiling a code in Java:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space |
When this exception occurs, it means that Java has run out of memory. If this code is still under development process, you should investigate for any memory leak issue. Or you could let Java to use more memory.
You can increase memory(heap size) by run java including these parameters:
-Xms[initial heap size] -Xmx[maximum heap size] |
For example, set initial heap size to 128m and maximum to 256m.
java -Xms128m -Xmx256m |
In NetBeans, simply goes to Project Properties –> Run.
Then you can add these parameters in VM Options.
do you know how do i set initial heap size to 128m in Jcreator?
I’m not sure on JCreator but there must be a setting similar to NetBeans that let you add argument when execute java.exe commmand.
Thx.
thanks, its very useful….
hiii.. i faced the same problem “Exception in thread “main” java.lang.OutOfMemoryError: Java heap space”
i’hv increase the heap from 32m until 1024m, but it did not work. 🙁
“Exception in thread “main†java.lang.OutOfMemoryError: Java heap spaceâ€. this is a problem i’ve been for two days now, how can i solve it in netbeans.