Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
355 views
in Technique[技术] by (71.8m points)

java - 启动JVM时,-Xms和-Xmx参数是什么?(What are the -Xms and -Xmx parameters when starting JVM?)

Please explain the use of Xms and Xmx parameters in JVMs.

(请说明XmsXmx参数的用法。)

What are the default values for them?

(它们的默认值是多少?)

  ask by Pankaj translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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内部数据结构分开分配在内存中。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...