-Xms 和 -Xmx 标志是否保留了机器的资源? [英] Do the -Xms and -Xmx flags reserve the machine's resources?

查看:20
本文介绍了-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 标志是否保留了机器的资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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