2

I encountered an error in Netbeans:

java.lang.OutOfMemoryError: Java heap space

This is the first time I encountered this and I don't know how to deal with it.

Can somebody explain this error message to me?

And how can I increase the heap memory? Thank you!

nhix
  • 81
  • 3
  • 13

2 Answers2

3

You can set it in NetBeans ide in the project properties -> Run -> VM options

Right click on your project "Properties" Select "Run" category. Enter your arguments(-Xmx512m) in the "VM Options" text box. Example: Putting -Xmx512m in the "VM Options" text box gives 512Mb maximum heap size to your Java program.

Viraj Nalawade
  • 3,137
  • 3
  • 28
  • 44
3

It could be an error related to Netbeans itself, then consider launching Netbeans with -Xmx key as it is described here: https://performance.netbeans.org/howto/jvmswitches/

Also it could be related to your particular project, you are trying to launch in Netbeans. In this case open project properties, go to Run section and extend memory for your project via -Xmx switch in VM Options as it is shown below:

enter image description here

  • Hi @Rafael, thank you for your answer. Do I have to restart my netbeans after I modified the VM Options? Because I've tried to modified it as Viraj instructed but nothing happens. Thanks again. – nhix May 04 '15 at 06:21
  • 1
    @nhix if you have changed Netbeans startup options, you need to restart Netbeans. If you have modified project options, restart your project. In case restarting your project did not help, modify Netbeans startup options to provide more memory to VM and restart Netbeans. If changing memory settings does not help, consider providing more memory to Netbeans/Your project, seems that volume you provided is not enough. –  May 04 '15 at 06:38
  • Hi @Rafael, thank you very much for your support and help. My problem is now fixed. I really appreciate your help. Thank you. ;) – nhix May 04 '15 at 07:21