OutOfMemoryError: insufficient memory in IntelliJ?

itro picture itro · Feb 9, 2015 · Viewed 33.5k times · Source

When I run my project in IntelliJ in debug mode I get the following error.

Does anybody know what is the cause? enter image description here

I already increased my heap size in idea.vmoptions:

-ea
-server
-Xms1g
-Xmx3G
-Xss16m
-Xverify:none
-XX:PermSize=512m
-XX:MaxPermSize=1024m

I already increased my heap size for compiler to 1024 as bellow: enter image description here

Answer

Mike Nakis picture Mike Nakis · Feb 9, 2015

You have tried:

  1. Increasing the heap size of the IntelliJ IDEA IDE, which has absolutely no effect on how much memory is available to your program at runtime, and

  2. Increasing the heap size for the compiler, which also has absolutely no effect on how much memory is available to your program at runtime.

Try Run menu -> Edit Configurations... -> find your project in the tree of projects on the left, look for VM options: in the panel on the right, and enter something there, according to information found here: What are the Xms and Xmx parameters when starting JVMs?

That having been said, I should also add that if you are running out of memory without knowingly doing extremely memory hungry stuff, then what you have in your hands is a bug which is causing your program to do runaway memory allocation, which will always be resulting in out-of-memory errors no matter how much you increase your heap size. In that case, you will need to look at your code, not at your project options.