【问题标题】:Increasing memory size with maven-exec-plugin使用 maven-exec-plugin 增加内存大小
【发布时间】:2015-09-03 11:47:52
【问题描述】:

我想使用 maven-exec-plugin 来运行我的课程。

class ThisTestLauncher {
    public static void main(String[] args) throws Exception {
    System.out.println(
        ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax()
    );
}

pom:

<artifactId>exec-maven-plugin</artifactId>
<configuration>
   <mainClass>com.my.ThisTestLauncher</mainClass>
   <arguments>
      <argument>-Xms512m</argument>
      <argument>-Xmx2g</argument>
   </arguments>
</configuration>

不过,我看到输出是 259522560,这就像 256m 大小。

的结果相同
<commandlineArgs>-Xms512m -Xmx2g</commandlineArgs>

这有什么问题?

【问题讨论】:

  • 被传递给 main 方法。这不是 JVM 参数。文档中关于 的描述不是很清楚。是否也传递给 main 方法?你能检查一下吗?作为替代方案,使用目标 exec:exec 并指定“java -Xmx512m -Xmx2g com.my.ThisTestLauncher”作为要执行的命令。见mojohaus.org/exec-maven-plugin/exec-mojo.html
  • 你说得对,谢谢

标签: java maven-2 heap-memory


【解决方案1】:

&lt;commandlineArgs&gt;&lt;arguments&gt; 被传递给 main 方法。它们不是 JVM 参数。

或者,使用目标exec:exec 并指定java -Xmx512m -Xmx2g com.my.ThisTestLauncher 作为您要执行的命令。见http://www.mojohaus.org/exec-maven-plugin/exec-mojo.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-09
    • 2020-10-04
    • 2021-03-31
    • 2014-04-23
    • 2013-02-14
    • 2012-03-13
    • 2011-03-26
    相关资源
    最近更新 更多