JVM命令启动选项重复

发布于 2024-12-18 22:27:37 字数 224 浏览 7 评论 0原文

我发现我们正在使用的一个遗留软件的启动属性格式错误,因此它接收这两个不相等的 xmx 作为属性:

java -jar myapp.jar -Xmx128m -Xmx512m 

我无权访问启动器源代码(无法修改它),所以我请问,这些参数重复有什么影响?我可以就这样离开吗,还是应该担心?将应用哪一种?

使用的 JVM 是 JRE 6 update 18

I have found a legacy software that we're using that has its launch properties malformed, so it receives these two unequal xmx as a properties:

java -jar myapp.jar -Xmx128m -Xmx512m 

I do not have access to the launcher source code(not being able to modify it), so I ask, what is the impact of the duplication of these parameters? Can I leave this in this way, or should I worry? Which one will be applied?

The JVM used is JRE 6 update 18

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

审判长 2024-12-25 22:27:37

一般来说,如果工具不拒绝重复项,通常会使用后一个选项,但除非该工具记录它,否则您不能指望这一点。

最好的办法是通过 RuntimetotalMemorymaxMemory< /a>:

public class HeapSize {
    public static final void main(String[] args) {
        Runtime rt = Runtime.getRuntime();
        System.out.println("Total currently: " + rt.totalMemory());
        System.out.println("Max:             " + rt.maxMemory());
        System.exit(0);
    }
}

我的 JVM(Linux 下的 Sun/Oracle 1.6.0_26-b03)上,后一个选项生效:

$ java -Xmx16m HeapSize
Total currently: 16121856
Max:             16121856
$ java -Xmx32m HeapSize
Total currently: 32178176
Max:             32178176
$ java -Xmx16m -Xmx32m HeapSize
Total currently: 32178176
Max:             32178176
$ java -Xmx16m -Xmx32m -Xmx128m HeapSize
Total currently: 59113472
Max:             119341056

In general, it's usually the latter option that gets used if a tool doesn't reject a duplicate, but you can't count on that unless the tool documents it.

Your best bet is to see what happens with your specific JVM, via Runtime's totalMemory and maxMemory:

public class HeapSize {
    public static final void main(String[] args) {
        Runtime rt = Runtime.getRuntime();
        System.out.println("Total currently: " + rt.totalMemory());
        System.out.println("Max:             " + rt.maxMemory());
        System.exit(0);
    }
}

On my JVM (Sun/Oracle 1.6.0_26-b03 under Linux), the latter option takes effect:

$ java -Xmx16m HeapSize
Total currently: 16121856
Max:             16121856
$ java -Xmx32m HeapSize
Total currently: 32178176
Max:             32178176
$ java -Xmx16m -Xmx32m HeapSize
Total currently: 32178176
Max:             32178176
$ java -Xmx16m -Xmx32m -Xmx128m HeapSize
Total currently: 59113472
Max:             119341056
○闲身 2024-12-25 22:27:37

我的理解是它将使用最后的设置。

My understanding it that it will use the last setting.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文