MXMLC Ant任务导致java.lang.OutOFMemoryError错误

8

我正在对一组Flex项目的代码进行更改,但这些代码并不是我编写的,并且设置为使用ant任务进行编译。我假设在最后一次提交时,代码库是稳定的,但是当我尝试使用MXMLC和ant构建项目时遇到了内存问题(请参见下面的堆栈跟踪)。之前,我只是收到了内存不足的错误。我尝试使用另一台机器并得到了更详细的异常信息(包括图像提取器的问题)。我尝试使用各种版本的SDK,我尝试用<exec executable="mxmlc">替换<mxmlc>标签,但没有成功。这是我的Java版本,以防它与此有关:

» java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01-279, mixed mode)

非常感谢您的帮助。谢谢!

Buildfile: build.xml

compileSWF:
     [echo] Compiling main.swf... 
    [mxmlc] Loading configuration file /Applications/Adobe Flash Builder 4 Plug-in/sdks/4.0.0beta2/frameworks/flex-config.xml
    [mxmlc] Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
    [mxmlc]     at java.awt.image.PixelGrabber.setDimensions(PixelGrabber.java:360)
    [mxmlc]     at sun.awt.image.ImageDecoder.setDimensions(ImageDecoder.java:62)
    [mxmlc]     at sun.awt.image.JPEGImageDecoder.sendHeaderInfo(JPEGImageDecoder.java:71)
    [mxmlc]     at sun.awt.image.JPEGImageDecoder.readImage(Native Method)
    [mxmlc]     at sun.awt.image.JPEGImageDecoder.produceImage(JPEGImageDecoder.java:119)
    [mxmlc]     at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:246)
    [mxmlc]     at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
    [mxmlc]     at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)
    [mxmlc] /src/com/amtrak/components/map/MapAsset.mxml: Error: exception during transcoding: Failed to grab pixels for image /src/assets/embed_assets/images/zoomed_map_wide.jpg
    [mxmlc] 
    [mxmlc] /src/com/amtrak/components/map/MapAsset.mxml: Error: Unable to transcode /assets/embed_assets/images/zoomed_map_wide.jpg.
    [mxmlc] 
    [mxmlc] Error: Java heap space
    [mxmlc] 
    [mxmlc] java.lang.OutOfMemoryError: Java heap space
    [mxmlc]     at java.util.ArrayList.<init>(ArrayList.java:112)
    [mxmlc]     at macromedia.asc.util.ObjectList.<init>(ObjectList.java:30)
    [mxmlc]     at macromedia.asc.parser.ArgumentListNode.<init>(ArgumentListNode.java:30)
    [mxmlc]     at macromedia.asc.parser.NodeFactory.argumentList(NodeFactory.java:116)
    [mxmlc]     at macromedia.asc.parser.NodeFactory.argumentList(NodeFactory.java:97)
    [mxmlc]     at flex2.compiler.mxml.ImplementationGenerator.generateBinding(ImplementationGenerator.java:563)
    [mxmlc]     at flex2.compiler.mxml.ImplementationGenerator.generateBindingsSetupFunction(ImplementationGenerator.java:864)
    [mxmlc]     at flex2.compiler.mxml.ImplementationGenerator.generateBindingsSetup(ImplementationGenerator.java:813)
    [mxmlc]     at flex2.compiler.mxml.ImplementationGenerator.generateInitializerSupportDefs(ImplementationGenerator.java:1813)
    [mxmlc]     at flex2.compiler.mxml.ImplementationGenerator.generateClassDefinition(ImplementationGenerator.java:1005)
    [mxmlc]     at flex2.compiler.mxml.ImplementationGenerator.<init>(ImplementationGenerator.java:201)
    [mxmlc]     at flex2.compiler.mxml.ImplementationCompiler.generateImplementationAST(ImplementationCompiler.java:498)
    [mxmlc]     at flex2.compiler.mxml.ImplementationCompiler.parse1(ImplementationCompiler.java:196)
    [mxmlc]     at flex2.compiler.mxml.MxmlCompiler.parse1(MxmlCompiler.java:168)
    [mxmlc]     at flex2.compiler.CompilerAPI.parse1(CompilerAPI.java:2851)
    [mxmlc]     at flex2.compiler.CompilerAPI.parse1(CompilerAPI.java:2804)
    [mxmlc]     at flex2.compiler.CompilerAPI.batch2(CompilerAPI.java:446)
    [mxmlc]     at flex2.compiler.CompilerAPI.batch(CompilerAPI.java:1274)
    [mxmlc]     at flex2.compiler.CompilerAPI.compile(CompilerAPI.java:1488)
    [mxmlc]     at flex2.compiler.CompilerAPI.compile(CompilerAPI.java:1375)
    [mxmlc]     at flex2.tools.Mxmlc.mxmlc(Mxmlc.java:282)
    [mxmlc]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [mxmlc]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [mxmlc]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [mxmlc]     at java.lang.reflect.Method.invoke(Method.java:597)
    [mxmlc]     at flex.ant.FlexTask.executeInProcess(FlexTask.java:280)
    [mxmlc]     at flex.ant.FlexTask.execute(FlexTask.java:225)
    [mxmlc]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    [mxmlc]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [mxmlc]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [mxmlc]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [mxmlc]     at java.lang.reflect.Method.invoke(Method.java:597)

BUILD FAILED
/src/build.xml:49: mxmlc task failed
5个回答

8

给Java虚拟机分配更多的堆空间,例如:

java -Xmx1024M

或者你需要的其他内容 :-). 在Linux(可能也适用于其他Unix系统)下,可以使用ant二进制文件执行以下操作:

ANT_OPTS="-Xmx1024M" ant 

谢谢。看起来这个方法可行,但只有当我将它提高到4GB时才有效! - Mims H. Wright

5

我们在一台没有安装Flex Builder的个人电脑上使用Ant构建Flex应用程序,唯一解决堆空间错误的方法是增加build.xml中的maxmemory参数。

设置ant_opts和java配置对我们无效。

<mxmlc file="${src-cp}/CP_main.mxml" output="${bin-dir}/CP/CP_main.swf" 
    show-unused-type-selector-warnings="false"
    static-link-runtime-shared-libraries="true" fork="true" maxmemory="1024m">

更多信息请参见http://tipila.com/tips/java-heap-error-when-building-flex-application-with-ant

这是关于使用Ant构建Flex应用程序时遇到Java堆错误的信息源。请点击上面的链接以获取更多信息。

为什么 show-unused-type-selector-warningsfalse - IgorGanapolsky

1

我在使用compc时遇到了类似的问题。唯一似乎对我有帮助的是设置fork="true" maxmemory="256m"


你是从哪里确定数字 256m 的? - IgorGanapolsky

0
在我的情况下,当我添加第五个SWF时,我正在编译几个不同的SWF,那时我遇到了内存错误。我解决它的方法是使用一些技巧。我通过使用exec ant任务为我正在编译的每个swf生成新的JVM。
<target name="main">
            <exec executable="ant" os="Mac OS X">
                <arg value="antTargetCompileSwf1"/>
            </exec>
            <exec executable="ant" os="Windows 2000,Windows NT,Windows XP,Windows 8">
                <arg value="antTargetCompileSwf1"/>
            </exec>
            <exec executable="ant" os="Mac OS X">
                <arg value="antTargetCompileSwf2"/>
            </exec>
            <exec executable="ant" os="Windows 2000,Windows NT,Windows XP,Windows 8">
                <arg value="antTargetCompileSwf2"/>
            </exec>
        </target>

这是一个例子,我在同一构建文件中引用了每个目标antTargetCompileSwf2,在该构建文件中包含最初引发内存错误的mxmlc任务


0
如果您正在Flash Builder中启动Ant任务,请转到“首选项> Java> 已安装的JRE> 编辑”,并在“默认VM参数”下添加Java的适当命令行参数,例如-Xmx4096M

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接