Do the -Xms and -Xmx flags reserve the machine#39;s resources?(-Xms 和 -Xmx 标志是否保留了机器的资源?)
问题描述
我知道JVM进程的-Xms
标志是允许JVM进程使用特定数量的内存来初始化它的进程.而关于Java应用程序的性能,通常建议在启动应用程序时将-Xms
和-Xmx
设置为相同的值,例如-Xms2048M -Xmx2048M
.
I know that the -Xms
flag of JVM process is to allow the JVM process to use a specific amount of memory to initialize its process. And in regard to performance of a Java application, it is often recommended to set the same values to both -Xms
and -Xmx
when starting the application, like -Xms2048M -Xmx2048M
.
我很好奇 -Xms
和 -Xmx
标志是否意味着 JVM 进程预留了特定数量的内存以防止同一进程中的其他进程机器不要使用它.
I'm curious whether the -Xms
and -Xmx
flags mean that the JVM process makes a reservation for the specific amount of memory to prevent other processes in the same machine from using it.
是这样吗?
推荐答案
Xmx
只是保留虚拟地址空间.Xms
实际上分配(提交)它,但不一定预先设置它.
Xmx
merely reserves virtual address space.
Xms
actually allocates (commits) it but does not necessarily prefault it.
操作系统对分配的响应方式各不相同.
How operating systems respond to allocations varies.
Windows 确实允许您保留非常大的地址空间块 (Xmx),但不允许过度使用 (Xms).限制由交换 + 物理定义.例外情况是大页面(需要通过组策略设置启用),这将受到物理内存的限制.
Windows does allow you to reserve very large chunks of address space (Xmx) but will not allow overcommit (Xms). The limit is defined by swap + physical. The exception are large pages (which need to be enabled with a group policy setting), which will limit it by physical ram.
Linux 行为更复杂,它取决于 vm.overcommit_memory
和相关的 sysctls 以及传递给 mmap 系统调用,在某种程度上可以通过 JVM 配置标志来控制.行为范围从 a) Xms 可以超过总内存 + 交换到 b) Xmx 被可用的物理内存限制.
Linux behavior is more complicated, it depends on the vm.overcommit_memory
and related sysctls and various flags passed to the mmap syscall, which to some extent can be controlled by JVM configuration flags. The behavior can range from a) Xms can exceed total ram + swap to b) Xmx is capped by available physical ram.
这篇关于-Xms 和 -Xmx 标志是否保留了机器的资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:-Xms 和 -Xmx 标志是否保留了机器的资源?
基础教程推荐
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 降序排序:Java Map 2022-01-01