java -Xms256m -Xmx2048m
-Xmx1024k
-Xmx512m
-Xmx8g
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
您可以在 IDE 中指定它。例如,对于 Eclipse 中的运行配置 → VM 参数 。您可以输入-Xmx800m -Xms500m
作为
上面已经解决了这个问题。仅添加部分默认值。
按照http://docs.oracle.com/cd/E13150_01/jrockit_jvm/jrockit/jrdocs/refman/optionX.html
Xmx 的默认值将取决于平台和系统中可用的内存量。
-Xmx<size> - to set the maximum Java heap size
-Xms<size> - to set the initial Java heap size
java -Xms256m -Xmx4g
-Xms用于启动的初始堆大小,但是,在工作过程中,由于用户不活动或 GC 迭代,堆大小可能小于-Xms 。这不是最小的必需堆大小。
-Xmx最大堆大小