【发布时间】: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