What are the -Xms and -Xmx parameters when starting JVM?
请解释在JVM中使用
标志
这意味着,您的JVM将以
1 | java -Xms256m -Xmx2048m |
内存标志也可以以不同的大小指定,如千字节、兆字节等。
1 2 3 | -Xmx1024k -Xmx512m -Xmx8g |
使用这些设置时,请记住这些设置是针对JVM堆的,并且JVM可以/将使用比分配给堆的大小更多的内存。从Oracle的文档中:
Note that the JVM uses more memory than just the heap. For example Java methods, thread stacks and native handles are allocated in memory separate from the heap, as well as JVM internal data structures.
运行命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 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选项为非标准选项,如有更改,恕不另行通知。
我希望这能帮助你理解
您可以在您的IDE中指定它。例如,对于运行配置→vm参数中的Eclipse。您可以输入
这个问题本身已经在上面讨论过了。只添加部分默认值。
根据http://docs.oracle.com/cd/e13150_01/jrockit_jvm/jrockit/jrdocs/refman/optionx.html
xmx的默认值将取决于平台和系统中可用的内存量。