简体   繁体   English

JVM根据给定的参数使用多少物理内存?

[英]How much physical memory does JVM uses based on the arguments given?

I would like to find out how much physical memory does JVM uses under the following situation: 我想找出在以下情况下JVM使用多少物理内存:

java -Xms2G -Xmx2G -XX:PermSize512M -version java -Xms2G -Xmx2G -XX:PermSize512M -version

I assume it is using min and max of 2GB + 512 MB - total of 2.5GB physical memory used? 我假设它正在使用最小和最大2GB + 512 MB-总共使用了2.5GB物理内存?

When will swap space come into play for memory usage? 交换空间何时会发挥作用以提高内存使用率?

在此处输入图片说明

Ref 1: https://plumbr.eu/outofmemoryerror/java-heap-space Ref 2: https://plumbr.eu/outofmemoryerror/out-of-swap-space 参考1: https//plumbr.eu/outofmemoryerror/java-heap-space参考2: https//plumbr.eu/outofmemoryerror/out-of-swap-space

How much physical memory does JVM uses based on the arguments given? JVM根据给定的参数使用多少物理内存?

The (virtual) memory footprint varies significantly depending on a number of factors in addition to the arguments. 除了参数之外,(虚拟)内存占用量还取决于许多因素,因此差异很大。

I assume it is using min and max of 2GB + 512 MB - total of 2.5GB physical memory used? 我假设它正在使用最小和最大2GB + 512 MB-总共使用了2.5GB物理内存?

First of all, the memory usage is likely to be larger than that. 首先,内存使用量可能会更大。 Additional memory occupied by: 占用的额外内存:

  • the (loaded) executable and shared libraries / DLLs comprising the JVM native codebase, 包含JVM本机代码库的(已加载的)可执行文件和共享库/ DLL,

  • off-heap memory segments that hold thread stacks, and 存放线程堆栈的堆外内存段,以及

  • off-heap memory used for direct-mapped files and other things, allocated by the JVM, application and 3rd-party native libraries. JVM,应用程序和第三方本机库分配的用于直接映射文件和其他内容的堆外内存。

Second, what we are talking about here is virtual memory usage, not physical memory usage. 其次,我们在这里谈论的是虚拟内存使用率,而不是物理内存使用率。 The physical memory usage will be less than the virtual memory. 物理内存使用量将小于虚拟内存。

Note that the actual physical memory usage typically depends on the overall system demand for memory, and is liable to fluctuate as system deals with competing demands by "paging" your JVM in and out. 请注意,实际的物理内存使用量通常取决于整个系统对内存的需求,并且随着系统通过“分页” JVM进出JVM处理竞争的需求时,实际的物理内存使用量可能会波动。

When will swap space come into play for memory usage? 交换空间何时会发挥作用以提高内存使用率?

Swap space is typically allocated as "backing" for the JVM processes virtual memory pages. 交换空间通常被分配为JVM处理虚拟内存页面的“后备”。 It "comes into play", if and when the operating system needs to take physical memory pages away from the JVM to give to other applications. 如果操作系统何时以及何时需要将物理内存页面从JVM上移走以提供给其他应用程序,它将“发挥作用”。 The JVM state in those pages are written to swap space, and then the pages are loaded with another application's state (eg from that application's swap space) and then mapped into the address space. 这些页面中的JVM状态被写入交换空间,然后将其他应用程序的状态(例如,来自该应用程序的交换空间)加载到页面中,然后映射到地址空间中。

For more information, read the Wikipedia page on virtual memory . 有关更多信息,请阅读虚拟内存上的Wikipedia页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM