2

I have imported a SBT project into IntelliJ(version 14). When I am trying to run something in the terminal, the console output is giving me "java.lang.OutOfMemoryError: Java heap space". I have tried increasing the size (Xms2048m, Xmx2048m) in *.vmoptions, and also in the IDE build settings of SBT project. I have restarted my machine as well. Nothing is working out. Any more inputs on it other than the things I have tried ?

P.S: I am running the project through the activator. When I am doing it from IntelliJ command prompt it's throwing me the error, but when I run the activator from windows command prompt, it is successfully running the application.

HookUp
  • 393
  • 1
  • 6
  • 20
  • Let's try that instead of changing file settings. Settings (Preferences on Mac) -> Compiler -> Java Compiler -> Maximum heap size (MB), and increase the size, then restart IntelliJ – Rafal May 09 '16 at 20:43
  • @Gavin yes I mean the terminal window in IntelliJ – HookUp May 09 '16 at 20:45
  • @Rafal, I am working on windows and I couldn't see the Maximum heap size in the settings of the compiler – HookUp May 09 '16 at 20:46
  • I don't have access to windows right now. Let's check maybe here: https://www.jetbrains.com/help/idea/2016.1/increasing-memory-heap.html?origin=old_help – Rafal May 09 '16 at 20:49
  • I have seen settings in windows(inside IntelliJ IDE-->Settings-->Compiler-->JavaCompiler). I am not declaring any environment variable for intelliJ, so that doesn't work me. – HookUp May 09 '16 at 20:53
  • @Hookup I removed my comment as to the best of my knowledge that is just a pass through to the actual host console, as per my answer below I think you will have to pass the memory settings you want to the command you are running in the console as command in the console will have no knowledge of any settings in your IntelliJ project. – Gavin May 09 '16 at 20:56

3 Answers3

2

You just asked your IDE:

  • -Xms2048m - ask VM to allocate 2048MB (2GB) heap on start
  • -Xmx2048m - limit heap to 2048MB

The reason could be:

  • You tried to exceed 2048MB
  • Allocating 2048MB on start was not possible (you probably just went out of RAM)
  • System thought so fast allocation was a malware.
Top Sekret
  • 748
  • 5
  • 21
1

I was getting a similar issue while building the project in IntelliJ what worked for me is to update the build memory size in settings as below:

Settings (or Preferences) -> Build, Execution, Deployment -> Compiler -> Shared build process heap size (Mbytes)

Pukhraj soni
  • 1,832
  • 2
  • 17
  • 11
0

I think you will need to provide the memory settings as parameters to the command you are running on the console.

To the best of my knowledge any parameters set inside IntelliJ will only be for use of IntelliJ itself, and when you run the project from the SBT window (I am assuming it works like the maven window). Also as far as I know the terminal window in IntelliJ is just a "pass through" to the underlying console of the host system.

Not sure you need it, but this seems to be a good explanation of the memory settings, and links to duplicate answers: What are the Xms and Xmx parameters when starting JVMs?

Community
  • 1
  • 1
Gavin
  • 1,725
  • 21
  • 34