What is the correct way to set ANT_OPTS on OS X?

I run "Error: Java heap heap, java.lang.OutOfMemoryError: Java heap space" when compiling an existing project on OS X (Snow Leopard).

I use the default 64-bit SDK for Java 1.6 by default and the default installation of Ant (both provided as part of the OS).

I ran into this problem in other OS environments and usually resolve it with ANT_OPTS to increase the allocated memory, but this does not seem to work.

I tried setting ANT_OPTS as follows:

In the same shell I entered

export ANT_OPTS = "- Xmx1024m 'ant build

I also tried setting the value to ~ / .bash_profile (which I got to make sure it was raised).

I eventually solved the memory problem by increasing the memory in the javac task in my Ant script, but this is not ideal (I would rather use ANT_OPTS).

What is the right way to increase the amount of heap memory when running Ant on OS X?

UPDATE:

It seems that I was wrong, and ANT_OPTS is removed as an exception. The problem is that I am deploying a javac task (as described in bkail below).

This leads me to the next question. Why does the JAVAC process run out of memory in OSX when the same code / ant script works fine on Linux? What is the difference between the standard OSX installation of Java, which means that it requires dedicated additional memory?

+3
source share
2 answers

javac memoryMaximumSize - , javac fork = "true", , javac JVM JVM Ant, , ANT_OPTS javac JVM, -Xmx. - :

<project>
  <script language="javascript"><![CDATA[
    importClass(java.lang.Runtime)
    project.setProperty("memoryMaximumSize", Runtime.getRuntime().maxMemory());
  ]]></script>
  <javac srcdir="." memoryMaximumSize="${memoryMaximumSize}" fork="true"/>
</project>

ant -verbose , javac:

[javac] Compilation arguments:
[javac] '-J-Xmx520290304'
+2

, , JVM "" "". "", . . :

http://java.sun.com/docs/hotspot/gc5.0/ergo5.html

java -version , :

java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)
+1

Source: https://habr.com/ru/post/1716536/


All Articles