Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij occasionally unable to reserve enough space for object heap

RESOLVED check below for solution.

I'm using Intellij Idea 2017.2.2. Below is my intellij Specs.

My Intellij would only occasionally fail a maven build or a jboss server start with the error

Error occurred during initialization of VM
Could not reserve enough space for 1048576KB object heap

If I were to run the maven build with the vm args of

-Xms512m -Xmx1024m

The build would fail 9 out of 10 times (not exactly every 10th, but just randomly). But on the 10th time it would work. I simply have to keep pressing the install button until it works.

This was a major problem before was that if I don't specify the vm args then the build would go about halfway then fail on running out of java heap space.

The same exact behavior can be observed for my jboss server (JBOSS6.4 - 7.5.0.Final redhat 21), where the server would fail to start 9 out of 10 times. Then start up as randomly as it does not.

Specs

IntelliJ IDEA 2017.2.2

Build #IU-172.3757.52, built on August 14, 2017

Licensed to -----

Subscription is active until May 31, 2018

JRE: 1.8.0_152-release-915-b10 amd64

JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Windows 7 6.1

What I tested

I upgraded from Intellij 2017.1 to 2017.2 and the behavior did not change.

I also tried to do the same on Eclipse which also did not help.

Clean restart of PC, then close all the unnecessary apps, open intellij do a maven build and yet it fails, but a few more clicks and it works inconsistently as usual. (note at this moment only 6gb out of 16 is used, there is no way there is an insufficiency with memory)

*Edits

This PC have 16 gb of ram. While the fails are happening about 9.5GBs are being used at that moment.

like image 752
user1111111 Avatar asked Aug 25 '17 16:08

user1111111


Video Answer


3 Answers

Ultimately I was able to resolve the issue by updating the proper JDK. My project was picking up on an incorrect JDK and hence was running the 32 Bit as opposed to 64 bit JDK.

Simply added the correct JDK under File > Project Settings.

It seemed that my project never required that much memory before, but once the need had risen, it seems that a 64 bit became required.

like image 93
user1111111 Avatar answered Oct 13 '22 10:10

user1111111


I have solved this problem by changing the build settings in Intellij. Please follow the below steps.

For SBT: 1. Go to File -> Settings -> Build, Execution Deployment -> sbt 2. Change the value of Maximum heap size, MB to your available memory. Ex. 512 (Previously this value was 1536, due to this I faced the problem)

For Maven: 1. Go to File -> Settings -> Build, Execution Deployment -> Maven -> Importing

  1. Change the value of VM options for importer to your available memory. Ex. -Xmx512m

Heap memory issue fix in Intellij

like image 4
Jeberdson Abraham Avatar answered Oct 13 '22 10:10

Jeberdson Abraham


I had to do the following options to get it pass the error.

Spec used: IDEA IntelliJ 2019.3.5 (Community Edition)

  1. Increase the memory in IntelliJ VM Options

    Step 1: Go to Help -> Edit Custom VM Options

    enter image description here

    Step2: Change the Heap sizes as given below

    enter image description here

  2. Run the app with increased memory by setting the VM options

    Run -> Edit Configurations

    enter image description here

like image 1
Madhu Tomy Avatar answered Oct 13 '22 09:10

Madhu Tomy