使用ant时 出现 java.lang.OutOfMemoryErro r: Java heap space的解决办法

 

在Linux的shell中,使用export设置ANT_OPTS变量,值为1G

export ANT_OPTS=-Xmx1g
ant

同理在windows的cmd中,使用set设置ANT_OPTS变量,值为1G

set ANT_OPTS=-Xmx1g
ant

如果想设置成1.5G,使用 -Xmx1536m

 

如果是javac任务,需要使用'memoryinitialsize' 和 'memorymaximumsize'来指定

javac   srcdir="${src}"
            destdir="${classes}"
            source="1.6"
            debug="true"
            fork="true"
            deprecation="off"
            memoryinitialsize="512m"
            memorymaximumsize="1024m"

 

 

如果报java.lang.OutOfMemoryError: PermGen space错误

设置方法:

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

 

 

参考:http://stackoverflow.com/questions/7494909/build-failed-java-lang-outofmemoryerror-java-heap-space

posted @ 2016-07-26 11:14  月色深潭  阅读(1679)  评论(0编辑  收藏  举报