如何解决PermGen内存不足错误?

时间:2015-05-26 07:39:17

标签: android ant environment-variables permgen dexguard

我正在使用ANT构建工具构建我的Android应用程序。

  1. 使用dexgaurd在本地计算机上运行时,它可以正常运行。
  2. 在不使用dexgaurd时,它在服务器上运行良好。
  3. 使用dexgaurd时,它在服务器上失败。
  4. 服务器规格:

                 total       used       free     shared    buffers     cached
    
    Mem:          7978       7328        649          0         32        391
    -/+ buffers/cache:       6904       1073
    Swap:         8188        486       7702
    

    以下是错误:

    [dexguard] java.lang.OutOfMemoryError: PermGen space
    [12:10:04]
    [dexguard-package-helper] The following error occurred while executing this line:
    /abc/def/custom_rules.xml:60: java.lang.OutOfMemoryError: PermGen space
    [12:10:04]
    [ant] The following error occurred while executing this line:
    /abc/def/custom_rules.xml:127: The following error occurred while executing this line:
    /abc/def/custom_rules.xml:60: java.lang.OutOfMemoryError: PermGen space
    

    以下是发生错误的行:

    <dexguard
                verbose="${verbose}"
                keystore="${key.store}"
                keystorepassword="${key.store.password}"
                keyalias="${key.alias}"
                keypassword="${key.alias.password}"
                printseeds="${obfuscate.absolute.dir}/seeds.txt"
                printusage="${obfuscate.absolute.dir}/usage.txt"
                printmapping="${obfuscate.absolute.dir}/mapping.txt"
    60 - >      configuration="@{configuration}">
                <configuration file="proguard-project.txt" />
                <configuration file="dexguard-project.txt" />
                <configuration file="dexguard-project-${build.target}.txt" />
                <dexguard-options />
                <libraryjar refid="project.target.class.path" />
            </dexguard>
    
    <dexguard-package-helper
          127 ->           configuration="${dexguard.dir}/lib/dexguard-${build.target}.pro">
                        <dexguard-options>
                            <injar path="${out.classes.absolute.dir}"     filter="**.class" />
                            <injar path="${source.absolute.dir}"          filter="!**.java,!.hg**,!**/.hg**,!.git**,!**/.git**,!.svn**,!**/.svn**,!CVS,!CVS/**,!**/CVS,!**/CVS/**,!.cvsignore,!**/.cvsignore,!SCCS,!SCCS/**,!**/SCCS,!**/SCCS/**,!**.orig,!**~,lib/*/*.so,!**.so,!**.keep,!**.DS_Store,!**.aidl,!**.rs,!**.rsh,!**.d,!**.java,!**.scala,!**.scc,!**.swp,!**.bak,!**thumbs.db,!**picasa.ini,!**package.html,!**overview.html,!**.AIDL,!**.RS,!**.RSH,!**.D,!**.JAVA,!**.SCALA,!**.SCC,!**.SWP,!**.BAK,!**THUMBS.DB,!**PICASA.INI,!**PACKAGE.HTML,!**OVERVIEW.HTML" />
                            <injar refid="project.all.jars.path"          filter="!org/w3c/dom/**,!org/xml/sax/**,!org/xmlpull/v1/**,!org/json/JSON*,!org/apache/commons/logging/Log.class,org/apache/http/Consts.class,org/apache/http/HttpHeaders.class,org/apache/http/entity/ContentType.class,org/apache/http/util/Args.class,org/apache/http/util/Asserts.class,org/apache/http/util/CharsetUtils.class,org/apache/http/util/NetUtils.class,org/apache/http/util/TextUtils.class,!org/apache/http/*,!org/apache/http/auth/*,!org/apache/http/auth/params/*,!org/apache/http/client/*,!org/apache/http/client/entity/*,!org/apache/http/client/methods/*,!org/apache/http/client/params/*,!org/apache/http/client/protocol/*,!org/apache/http/client/utils/*Utils.class,!org/apache/http/conn/*,!org/apache/http/conn/params/*,!org/apache/http/conn/routing/*,!org/apache/http/conn/scheme/*,!org/apache/http/conn/ssl/*,!org/apache/http/conn/util/*,!org/apache/http/cookie/*,!org/apache/http/cookie/params/*,!org/apache/http/entity/*,!org/apache/http/impl/*,!org/apache/http/impl/auth/*,!org/apache/http/impl/client/*,!org/apache/http/impl/conn/*,!org/apache/http/impl/conn/tsccm/*,!org/apache/http/impl/cookie/*,!org/apache/http/impl/entity/*,!org/apache/http/impl/io/*,!org/apache/http/io/*,!org/apache/http/message/*,!org/apache/http/params/*,!org/apache/http/protocol/*,!org/apache/http/util/*,META-INF/services/**,!META-INF/**,!.hg**,!**/.hg**,!.git**,!**/.git**,!.svn**,!**/.svn**,!CVS,!CVS/**,!**/CVS,!**/CVS/**,!.cvsignore,!**/.cvsignore,!SCCS,!SCCS/**,!**/SCCS,!**/SCCS/**,!**.orig,!**~,**.class,lib/*/*.so,!**.so,!**.keep,!**.DS_Store,!**.aidl,!**.rs,!**.rsh,!**.d,!**.java,!**.scala,!**.scc,!**.swp,!**.bak,!**thumbs.db,!**picasa.ini,!**package.html,!**overview.html,!**.AIDL,!**.RS,!**.RSH,!**.D,!**.JAVA,!**.SCALA,!**.SCC,!**.SWP,!**.BAK,!**THUMBS.DB,!**PICASA.INI,!**PACKAGE.HTML,!**OVERVIEW.HTML" />
                            <injar path="${out.native.libs.absolute.dir}" filter="lib/*/*.so" />
                            <injar path="${out.absolute.dir}/${resource.package.file.name}" />
                            <outjar path="${out.final.file}" />
                        </dexguard-options>
                    </dexguard-package-helper>
    

    以下是环境变量及其值:ANT_OPTS

    [echo] ant build config -Xms1024m -Xmx2048m -XX:PermSize=1024m -XX:MaxPermSize=2048m -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled
    

    我已将XX:MaxPermSize更改为4096,但仍然会出现相同的错误。它始终在这一点上失败,无论-Xms -Xmx -XX值是什么。我是否必须为环境添加一些其他值才能使其正常工作。这类问题的一般解决方案是增加-XX中的内存值:MaxPermSize但它没有帮助

    更多上下文:ant构建了8个应用程序。构建工作正常,直到第6个应用程序,并且它们都具有类似的custom_rules.xml文件。但它在构建第7个应用程序时失败了。

    如果您需要更多信息,请在评论部分提及,我会添加它。我已经搜索了很多关于这个问题并尝试使用解决方案解决它,但从未成功。

0 个答案:

没有答案
相关问题