Build Failed java.lang.OutOfMemoryError: Java heap space

后端 未结 4 2083
情深已故
情深已故 2021-01-31 09:21

I am facing this issue while building my build.xml.

BUILD FAILED
java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:2786)
            


        
相关标签:
4条回答
  • 2021-01-31 10:02

    (For < Java 8, permgen doesn't apply to Java 8 and up)

    For benefit of those who got a similar trace with the word "PermGen" in the Error message,

    java.lang.OutOfMemoryError: PermGen space
    

    Increasing the perm-gean space in ANT_OPTS (preferably, though not necessarily along with the Max heap size) should solve the issue

    example

    export ANT_OPTS="-Xmx2g -XX:MaxPermSize=512m"
    

    Adjust the numbers as per your your need.

    Cheers!

    0 讨论(0)
  • 2021-01-31 10:21

    It sounds like you need to launch your JVM with a larger memory limit. Try something like (if you're using Bourne shell):

    export ANT_OPTS=-Xmx1g
    ant
    

    or, if you use cmd under Windows:

    set ANT_OPTS=-Xmx1g
    ant
    

    Above, the 1g means 1 GB. You can tweak that to whatever you like; for example, if you want to use 1.5 GB, you can use -Xmx1536m.

    0 讨论(0)
  • 2021-01-31 10:21

    If 'javac' task is used with fork option then , javac will run in his own process and memory should be directly assigned to the javac using 'memoryinitialsize' and 'memorymaximumsize':

    javac   srcdir="${src}"
                destdir="${classes}"
                source="1.6"
                debug="true"
                fork="true"
                deprecation="off"
                memoryinitialsize="512m"
                memorymaximumsize="1024m"
    
    0 讨论(0)
  • 2021-01-31 10:21

    You need to set ANT_OPTS to next higher level in dx.bat file.which is located \build-tools\versions\dx.bat. set defaultXmx=-Xmx2048M I set it to 2GB.

    0 讨论(0)
提交回复
热议问题