Exception in thread “main” java.lang.OutOfMemoryError: Java heap space
Java, Programming January 15th, 2007When this exception occurs, it means java runs out of 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.
Related post
No related posts.




March 13th, 2008 at 2:32 am
do you know how do i set initial heap size to 128m in Jcreator?
March 13th, 2008 at 9:03 am
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.
January 7th, 2009 at 6:10 pm
Thx.
July 18th, 2010 at 6:51 am
thanks, its very useful….
June 12th, 2011 at 5:08 am
Hello nice thread we have going there.
June 13th, 2011 at 3:26 am
Just examined the thread. Amazing work.
August 16th, 2011 at 3:19 am
Cordial Post. It’s surely a dialect right good article. I noticed all your important points. Thanks
August 28th, 2011 at 9:48 am
Hey All! im here in finally say Hey like the topic says. i been troling around your forum for a few months now and i want to participate finally.
November 18th, 2011 at 7:25 am
Hello. everyone.
would like to make new friends with you guys.
January 5th, 2012 at 3:47 am
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.