本文介绍了构建失败java.lang.OutOfMemoryError:Java堆空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面对这个问题,同时建立我的build.xml。

 构建失败
java.lang.OutOfMemoryError:Java堆空间
    在java.util.Arrays.copyOf(Arrays.java:2786)
    在java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
    在组织codehaus.cargo.module.DefaultJarArchive<&初始化GT;(DefaultJarArchive。
Java的:75)
    在组织codehaus.cargo.module.DefaultJarArchive<&初始化GT;(DefaultJarArchive。
的java:56)
    在组织codehaus.cargo.module.webapp.DefaultWarArchive<&初始化GT;(DefaultWarA
rchive.java:69)
    在org.apache.cactus.integration.ant.CactifyWarTask.addJarWithClass(C振动
ifyWarTask.java:652)
    在org.apache.cactus.integration.ant.CactifyWarTask.addCactusJars(Cactif
yWarTask.java:627)
    在org.apache.cactus.integration.ant.CactifyWarTask.execute(CactifyWarTa
sk.java:519)
    在org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    在sun.reflect.GeneratedMethodAccessor31.invoke(来源不明)
    在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
    在java.lang.reflect.Method.invoke(Method.java:597)
    在org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
答:106)
    在org.apache.tools.ant.Task.perform(Task.java:348)
    在org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
    在net.sf.antcontrib.logic.IfTask.execute(IfTask.java:197)
    在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)
    在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl。
Java的:39)
    在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
    在java.lang.reflect.Method.invoke(Method.java:597)
    在org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
答:106)
    在org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:154)
    在org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    在sun.reflect.GeneratedMethodAccessor31.invoke(来源不明)
    在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
    在java.lang.reflect.Method.invoke(Method.java:597)
    在org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
答:106)
    在org.apache.tools.ant.Task.perform(Task.java:348)
    在org.apache.tools.ant.Target.execute(Target.java:357)
    在org.apache.tools.ant.Target.performTasks(Target.java:385)
    在org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
    在org.apache.tools.ant.Project.executeTarget(Project.java:1306)


解决方案

这听起来像你需要用更大的内存限制启动您的JVM。 (如果你使用Bourne shell)中尝试这样的:

 出口ANT_OPTS = -Xmx1g
蚂蚁

或者,如果你使用 CMD Windows下:

 设置ANT_OPTS = -Xmx1g
蚂蚁

以上,在1克表示1 GB。您也可以自行调整到任何您喜欢的;例如,如果你想使用1.5 GB,您可以使用 -Xmx1536m

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)
    at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
    at org.codehaus.cargo.module.DefaultJarArchive.<init>(DefaultJarArchive.
java:75)
    at org.codehaus.cargo.module.DefaultJarArchive.<init>(DefaultJarArchive.
java:56)
    at org.codehaus.cargo.module.webapp.DefaultWarArchive.<init>(DefaultWarA
rchive.java:69)
    at org.apache.cactus.integration.ant.CactifyWarTask.addJarWithClass(Cact
ifyWarTask.java:652)
    at org.apache.cactus.integration.ant.CactifyWarTask.addCactusJars(Cactif
yWarTask.java:627)
    at org.apache.cactus.integration.ant.CactifyWarTask.execute(CactifyWarTa
sk.java:519)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
    at net.sf.antcontrib.logic.IfTask.execute(IfTask.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
    at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:154)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.Target.performTasks(Target.java:385)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
解决方案

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.

这篇关于构建失败java.lang.OutOfMemoryError:Java堆空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 01:40