在Java中, -Xms
设置初始Java堆大小,而-Xmx
设置最大Java堆大小。
1.一些java -Xms -Xmx
示例:
2.默认的初始和最大Java堆大小是根据这种人体工程学算法分配的,还请阅读本文– 查找Java堆内存大小
3.如果Java进程超出了-Xmx
最大Java堆大小,则将引发流行的java.lang.OutOfMemoryError
。
4.对于其他选项,请运行此java -X
-Xbatch disable background compilation
-Xbootclasspath/a:<directories and zip/jar files separated by ;>
append to end of bootstrap class path
-Xcheck:jni perform additional checks for JNI functions
-Xcomp forces compilation of methods on first invocation
-Xdebug provided for backward compatibility
-Xdiag show additional diagnostic messages
-Xfuture enable strictest checks, anticipating future default
-Xint interpreted mode execution only
displays more detailed JVM version information than the
-Xloggc:<file> log GC status to a file with time stamps
-Xmixed mixed mode execution (default)
-Xmn<size> sets the initial and maximum size (in bytes) of the heap
for the young generation (nursery)
-Xms<size> set initial Java heap size
-Xmx<size> set maximum Java heap size
-Xnoclassgc disable class garbage collection
-Xrs reduce use of OS signals by Java/VM (see documentation)
-Xshare:auto use shared class data if possible (default)
-Xshare:off do not attempt to use shared class data
-Xshare:on require using shared class data, otherwise fail.
-XshowSettings show all settings and continue
show all settings and continue
show all locale related settings and continue
-XshowSettings:properties
show all property settings and continue
show all vm related settings and continue
(Linux Only) show host system or container
configuration and continue
-Xss<size> set java thread stack size
-Xverify sets the mode of the bytecode verifier
参考文献
翻译自: https://mkyong.com/java/java-what-is-xms-and-xmx-parameter/