Hoohoo
Hoohoo

Reputation: 451

How to change runtime JAVA heap space in intellij IDEA on MacOS?

I'm getting Exception in thread "main" java.lang.OutOfMemoryError: Java heap space when running some main object in scala with IntelliJ Idea, with the "^R" shortcut or Right click-> run 'mainObjName'

This program runs without problem if using sbt:

$ JAVA_OPTS="-Xmx4096m" sbt
sbt:prj> run mainobj

With the search results got from this site, I tried to set the heap space to 4096m in :

1.Preferences->Build Tools->sbt->Maximum heap size,MB

2.Preferences->Compiler->Build process heap size(Mbytes)

3.Preferences->Compiler->Scala Compiler->Scala Compiler Server->JVM Maximum heap size,MB

4.Preferences->Build Tools->Maven->Runner->VM Options (with -Xmx4096m)

But none of these works.

I'm running a memory hungry program, and this is clearly not a build time error but some thing happened during runtime. So, How to change the maximum heap size for running a program in IntelliJ Idea?

btw, the program runs fine on linux workstation with much more memory, but seems the default heap size configuration is the same on the IntelliJ Idea on MacOS vs Linux. seems java consumes more memory on MacOS?

Upvotes: 0

Views: 4941

Answers (1)

Kolmar
Kolmar

Reputation: 14224

It seems, that all the options you've tried are setting the memory for various compiler facilities.

You could try to change the memory available for the runtime by setting the VM options to -Xmx4096m in the configuration you are running. You can find the configuration with your mainObjName under Run -> Edit Configurations... -> Application

Upvotes: 3

Related Questions