加速Java -Xms和-Xmx选项的权衡 [英] Speed tradeoff of Java's -Xms and -Xmx options

查看:490
本文介绍了加速Java -Xms和-Xmx选项的权衡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于这两个命令

A:

$ java -Xms10G -Xmx10G myjavacode input.txt

B:

$ java -Xms5G -Xmx5G myjavacode input.txt



<我有两个问题:

I have two questions:


  1. 由于命令A使用其参数保留更多内存,A运行速度会比B快吗?

  2. -Xmx -Xms 如何影响正在运行的进程和我的程序的输出?

  1. Since command A reserves more memory with its parameters, will A run faster than B?
  2. How do -Xmx and -Xms affect the running process and the output of my program?


推荐答案

这取决于你的java使用的GC。并行GC可能在更大的内存设置上工作得更好 - 虽然我不是这方面的专家。

It depends on the GC your java is using. Parallel GCs might work better on larger memory settings - I'm no expert on that though.

一般来说,如果你有更大的内存,那么它需要更少的GC -ed-有很多垃圾的空间。但是,当涉及到GC时,GC必须处理更多内存 - 这反过来可能会更慢。

In general, if you have larger memory the less frequent it needs to be GC-ed - there is lots of room for garbage. However, when it comes to a GC, the GC has to work on more memory - which in turn might be slower.

这篇关于加速Java -Xms和-Xmx选项的权衡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆