欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

Java –什么是-Xms和-Xmx参数? 有大用

在Java中, -Xms设置初始Java堆大小,而-Xmx设置最大Java堆大小。

1.一些java -Xms -Xmx示例:

  1. # Start with 128MB of memory, and allow the Java process to use up to 1024MB of memory.
  2. java -Xms128m -Xmx1024m
  1. # Start with 256MB of memory, and allow the Java process to use up to 4G (4096MB) of memory.
  2. java -Xms256m -Xmx4g

2.默认的初始和最大Java堆大小是根据这种人体工程学算法分配的,还请阅读本文– 查找Java堆内存大小

3.如果Java进程超出了-Xmx最大Java堆大小,则将引发流行的java.lang.OutOfMemoryError 。

4.对于其他选项,请运行此java -X

  1. > java -X
  2. -Xbatch           disable background compilation
  3. -Xbootclasspath/a:<directories and zip/jar files separated by ;>
  4. append to end of bootstrap class path
  5. -Xcheck:jni       perform additional checks for JNI functions
  6. -Xcomp            forces compilation of methods on first invocation
  7. -Xdebug           provided for backward compatibility
  8. -Xdiag            show additional diagnostic messages
  9. -Xfuture          enable strictest checks, anticipating future default
  10. -Xint             interpreted mode execution only
  11. -Xinternalversion
  12. displays more detailed JVM version information than the
  13. -version option
  14. -Xloggc:<file>    log GC status to a file with time stamps
  15. -Xmixed           mixed mode execution (default)
  16. -Xmn<size>        sets the initial and maximum size (in bytes) of the heap
  17. for the young generation (nursery)
  18. -Xms<size>        set initial Java heap size
  19. -Xmx<size>        set maximum Java heap size
  20. -Xnoclassgc       disable class garbage collection
  21. -Xrs              reduce use of OS signals by Java/VM (see documentation)
  22. -Xshare:auto      use shared class data if possible (default)
  23. -Xshare:off       do not attempt to use shared class data
  24. -Xshare:on        require using shared class data, otherwise fail.
  25. -XshowSettings    show all settings and continue
  26. -XshowSettings:all
  27. show all settings and continue
  28. -XshowSettings:locale
  29. show all locale related settings and continue
  30. -XshowSettings:properties
  31. show all property settings and continue
  32. -XshowSettings:vm
  33. show all vm related settings and continue
  34. -XshowSettings:system
  35. (Linux Only) show host system or container
  36. configuration and continue
  37. -Xss<size>        set java thread stack size
  38. -Xverify          sets the mode of the bytecode verifier

参考文献

翻译自: https://mkyong.com/java/java-what-is-xms-and-xmx-parameter/

来自 https://blog.csdn.net/cyan20115/article/details/106548703/


普通分类: