Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant Plugin Task IntelliJ java.lang.OutOfMemoryError

Environment:

IntelliJ IDEA 2016.3.1 Build #IU-163.9166.29, built on December 9, 2016 JRE: 1.8.0_112-release-408-b2 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Mac OS 10.12.2

I have the Ant Support plugin installed in IntelliJ and am executing a build.xml script (see below for build.xml contents). I am getting the following error when executing the script.

java.lang.OutOfMemoryError: Java heap space.

I have googled for an hour or so and have tried adding memory parameters to shell/batch script and increasing IntelliJ compiler heap space to no avail. Just to be clear I'm using the Ant Build tool window in IntelliJ to start the execution of the Ant task(s). What setting(s) am I missing to adjust the available memory to the Java compiler?

<project name="Ant Deploy" default="deployProj" basedir="." xmlns:sf="antlib:com.salesforce">

    <property file="build.properties"/>
    <property environment="env"/>

    <!-- Test out deploy and retrieve verbs for package 'mypkg' -->
    <target name="deployProj">
        <taskdef resource="com/salesforce/antlib.xml" uri="antlib:com.salesforce">
            <classpath>
                <pathelement location="ant-salesforce.jar" />
            </classpath>
        </taskdef>

        <!-- Upload the contents of the "dst" package -->
        <sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" maxPoll="500" pollWaitMillis="150000"
      deployRoot="deployRootDir" rollbackOnError="false"/>
    </target>
</project>
like image 812
Ian G Avatar asked Feb 20 '17 18:02

Ian G


1 Answers

Much to my surprise the solution was very simple and there are two ways I discovered to access the parameter I needed to change.

Within the Ant Build tool window of IntelliJ

  1. Click the Properties icon (the one with checkboxes with one checked). See this screenshot from the Ant Build tool window. In this screenshot it is the 7th icon (counting left to right).

    enter image description here

OR

  1. Right click on one of the Ant project names or tasks listed inside the Ant Build window to access the context menu and select Properties

Once in the Build File Properties popup dialog you should see the setting Maximum heap size (Mb). In my case it was defaulted to 128 Mb. Increase the value of this setting as you see fit (512 Mb worked for my scenario). Press OK and attempt to run the Ant task(s) again. The java.lang.OutOfMemoryError: Java heap space. error should go away given you have increased the Maximum heap size (Mb) enough.

like image 172
Ian G Avatar answered Sep 27 '22 20:09

Ian G