The flag Xmx
specifies the maximum memory allocation pool for a Java virtual machine (JVM), while Xms
specifies the initial memory allocation pool.
(标志Xmx
指定Java虚拟机(JVM)的最大内存分配池,而Xms
指定初始内存分配池。)
This means that your JVM will be started with Xms
amount of memory and will be able to use a maximum of Xmx
amount of memory.
(这意味着您的JVM将以Xms
的内存量启动,并且最多可以使用Xmx
的内存量。)
For example, starting a JVM like below will start it with 256 MB of memory and will allow the process to use up to 2048 MB of memory: (例如,启动如下所示的JVM将以256 MB的内存启动它,并将允许该进程使用最多2048 MB的内存:)
java -Xms256m -Xmx2048m
The memory flag can also be specified in different sizes, such as kilobytes, megabytes, and so on.
(也可以以不同的大小指定内存标志,例如千字节,兆字节等。)
-Xmx1024k
-Xmx512m
-Xmx8g
The Xms
flag has no default value, and Xmx
typically has a default value of 256 MB.
(Xms
标志没有默认值,而Xmx
通常具有256 MB的默认值。)
A common use for these flags is when you encounter a java.lang.OutOfMemoryError
. (这些标志的常见用法是当您遇到java.lang.OutOfMemoryError
。)
When using these settings, keep in mind that these settings are for the JVM's heap , and that the JVM can/will use more memory than just the size allocated to the heap.
(使用这些设置时,请记住,这些设置用于JVM的堆 ,并且JVM可以/将使用的内存比分配给堆的大小更多。)
From Oracle's documentation : (从Oracle文档中 :)
Note that the JVM uses more memory than just the heap.
(请注意,JVM使用的内存不仅仅是堆。)
For example Java methods, thread stacks and native handles are allocated in memory separate from the heap, as well as JVM internal data structures. (例如,Java方法,线程堆栈和本机句柄与堆以及JVM内部数据结构分开分配在内存中。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…