gpt4 book ai didi

ant - Sonar 分析给出内存不足错误,我应该增加 Ant 或 Sonar 服务器的 JVM 堆空间吗?

转载 作者:行者123 更新时间:2023-12-04 10:26:39 27 4
gpt4 key购买 nike

我正在 Sonar 中分析一个大型项目并收到以下错误:

[sonar:sonar] 03:55:39.511 INFO  p.PhasesTimeProfiler - Execute decorators...

BUILD FAILED
[...]
[...] java.lang.OutOfMemoryError: Java heap space
at org.sonar.batch.index.MeasurePersister.model(MeasurePersister.java:127)
at org.sonar.batch.index.MeasurePersister.getMeasuresToSave(MeasurePersister.java:117)
at org.sonar.batch.index.MeasurePersister.dump(MeasurePersister.java:70)
at org.sonar.batch.index.DefaultPersistenceManager.dump(DefaultPersistenceManager.java:63)
at org.sonar.batch.phases.Phases.execute(Phases.java:95)
at org.sonar.batch.bootstrap.ProjectModule.doStart(ProjectModule.java:139)
at org.sonar.batch.bootstrap.Module.start(Module.java:83)
at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:131)
at org.sonar.batch.bootstrap.BatchModule.doStart(BatchModule.java:121)
at org.sonar.batch.bootstrap.Module.start(Module.java:83)
at org.sonar.batch.bootstrap.BootstrapModule.doStart(BootstrapModule.java:121)
at org.sonar.batch.bootstrap.Module.start(Module.java:83)
at org.sonar.batch.Batch.execute(Batch.java:104)
at org.sonar.ant.Launcher.execute(Launcher.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.sonar.ant.SonarTask.delegateExecution(SonarTask.java:244)
at org.sonar.ant.SonarTask.execute(SonarTask.java:193)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:442)

我应该增加正在运行的 Sonar 服务器的 Java 堆空间,还是执行 Sonar 作业的 Ant 目标?

最佳答案

从堆栈跟踪中可以看出,Ant 开始进行 Sonar 分析,因此您应该为 Ant 运行的 VM 增加堆空间。

这是一个非常相似的问题顺便说一句:How to increase Sonar Java heap space

对于命令行 Ant 用法

引用 Mark O'Connor 对另一个问题的回答:

The Sonar ANT task executes as part of ANT so you need to set the JVM heap using the standard ANT environment parameter. For example:

export ANT_OPTS=-Xmx256m



评论:
  • 这是用于 Linux,对于 Windows,使用 set命令
  • 这是严格的堆空间。为 Permgen , 使用 -XX:MaxPermSize=<desired amount>

  • 这是一个更相似的问题: Build Failed java.lang.OutOfMemoryError: Java heap space

    对于 Eclipse IDE

    文章引述 http://soenkerohde.com/2008/06/change-eclipse-ant-settings-when-you-run-out-of-memory/

    • In Eclipse open menu: Run->External Tools->Open External Tools Dialog
    • Select the build script you want to change on the left
    • Select the JRE tab on the right
    • Set the following as VM arguments: -Xms768m -Xmx1024m -XX:MaxPermSize=512m


    对于 IntelliJ Idea

    这个论坛帖子很有用: ANT build java heap space

    引用答案:

    Please make sure that you increased heap in a correct place. You need to click 'Properties' button in IDEA's Ant tool window and edit 'Maximum heap size (Mb)' field there.



    此外,来自 IntelliJ Idea 页面: Increasing Memory Heap

    引自文章:

    The memory heap of the build process is independent of IntelliJ IDEA memory heap, and is released after the build process is complete.

    To increase a memory heap: Open the Build File Properties dialog box. In the Maximum heap size field, type the required amount of memory.



    对于 Jenkins 持续集成和 Ant 构建

    这个问题很有用: How to use the Java Options in jenkins ant build tool to set ANT_OPTS

    引用答案:

    Set the JAVA OPTIONS as -Xmx512m -XX:MaxPermSize=256m only without the ANT_OPTS=



    对于 Maven 构建 ,本文有用: How to increase maven heapspace in hudson builds

    1. Navigate to your hudson job,
    2. click Configure,
    3. scroll down to the Build section, and
    4. click the Advanced button.
    5. Enter this into MAVEN_OPTS: -Xmx512m -XX:MaxPermSize=128m

    关于ant - Sonar 分析给出内存不足错误,我应该增加 Ant 或 Sonar 服务器的 JVM 堆空间吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14253218/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com