3 回答

TA贡献1854条经验 获得超8个赞
国旗Xmx
指定Java虚拟机(JVM)的最大内存分配池,而Xms
指定初始内存分配池。
这意味着您的jvm将在Xms
内存的数量,并且将能够最大限度地使用Xmx
内存的数量。例如,像下面这样启动JVM将使用256 MB的内存启动它,并允许进程使用最多2048 MB的内存:
java -Xms256m -Xmx2048m
还可以指定不同大小的内存标志,例如千字节、兆字节等。
-Xmx1024k-Xmx512m-Xmx8g
这个Xms
标志没有默认值,并且Xmx
默认值通常为256 MB。这些标志的一个常见用途是当您遇到java.lang.OutOfMemoryError
.
在使用这些设置时,请记住这些设置是针对JVM的堆,而且JVM可以/将使用更多的内存,而不仅仅是分配给堆的大小。
请注意,JVM使用的内存比堆更多。例如,Java方法、线程堆栈和本机句柄是在与堆分离的内存以及JVM内部数据结构中分配的。

TA贡献1770条经验 获得超3个赞
运行命令java -X你会得到一张清单-X备选方案:
C:\Users\Admin>java -X
-Xmixed mixed mode execution (default)
-Xint interpreted mode execution only
-Xbootclasspath:<directories and zip/jar files separated by ;>
set search path for bootstrap classes and resources
-Xbootclasspath/a:<directories and zip/jar files separated by ;>
append to end of bootstrap class path
-Xbootclasspath/p:<directories and zip/jar files separated by ;>
prepend in front of bootstrap class path
-Xdiag show additional diagnostic messages
-Xnoclassgc disable class garbage collection
-Xincgc enable incremental garbage collection
-Xloggc:<file> log GC status to a file with time stamps
-Xbatch disable background compilation
-Xms<size> set initial Java heap size.........................
-Xmx<size> set maximum Java heap size.........................
-Xss<size> set java thread stack size
-Xprof output cpu profiling data
-Xfuture enable strictest checks, anticipating future default
-Xrs reduce use of OS signals by Java/VM (see documentation)
-Xcheck:jni perform additional checks for JNI functions
-Xshare:off do not attempt to use shared class data
-Xshare:auto use shared class data if possible (default)
-Xshare:on require using shared class data, otherwise fail.
-XshowSettings show all settings and continue
-XshowSettings:all show all settings and continue
-XshowSettings:vm show all vm related settings and continue
-XshowSettings:properties show all property settings and continue
-XshowSettings:locale show all locale related settings and continue
-X选项是非标准的,如有更改,恕不另行通知.
我希望这能帮助你理解Xms, Xmx还有很多其他最重要的事情。*)
添加回答
举报