Ant-OutOfMemoryError错误解决

作者:聂勇 欢迎转载,请保留作者信息并说明文章来源!

环境

  • Windows Xp / SUSE Linux 9
  • apache-ant-1.7.1

1、java.lang.OutOfMemoryError

执行Ant脚本,编译项目时报如下错误信息:

1
# # An unexpected error has been detected by Java Runtime Environment: # # java.lang.OutOfMemoryError: requested 43888 bytes for GrET in C:\BUILD_AREA\jdk6_12\hotspot\src\share\vm\utilities\growableArray.cpp. Out of swap space? # # Internal Error (allocation.inline.hpp:42), pid=168, tid=2236 # Error: GrET in C:\BUILD_AREA\jdk6_12\hotspot\src\share\vm\utilities\growableArray.cpp # # Java VM: Java HotSpot(TM) Client VM (11.2-b01 mixed mode, sharing windows-x86) # An error report file with more information is saved as: # D:\QQDownload\aiwm\aiwmWeb\build\hs_err_pid168.log # # If you would like to submit a bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp #

编译项目失败。

解决方法:增大Ant可以使用的内存。
设置系统环境变量
Windows操作系统:

1
set ANT_OPTS=-Xms128m -Xmx256m

Unix/Linux操作系统:

1
export ANT_OPTS=-Xms128m -Xmx256m