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

查看:92
本文介绍了-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以及传递给

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天全站免登陆