Do the -Xms and -Xmx flags reserve the machine's resources?

前端 未结 3 666
眼角桃花
眼角桃花 2021-01-01 15:31

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

3条回答
  •  时光说笑
    2021-01-01 15:57

    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 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 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.

提交回复
热议问题