简体   繁体   中英

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:

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?

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

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

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?

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,

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

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.

When will swap space come into play for memory usage?

Swap space is typically allocated as "backing" for the JVM processes virtual memory pages. 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. 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.

For more information, read the Wikipedia page on virtual memory .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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