小fish 发表于 2017-1-28 13:08:28

tomcat使用的JVM参数

  最近的项目遇到分配给JVM的内存不足的问题,解决的同时,发现一些有意思的参数,可以考虑今后使用并测试下。
  1.分配给JVM内存,
  这个基本上就是
  -Xms999m 和 -Xmx999m,Xms是程序初始内存,Xmx是程序可用最大内存。
  2.分配给Permanent Generation的内存,
  -XX:MaxPermSize=256m
  Size of the Permanent Generation.
  3.new/old generation的比值
  -XX:NewRatio=2
  Ratio of new/old generation sizes. -client: 4 (1.3) 8 (1.3.1+), x86: 12]
  4.利用多核CPU
  -XX:+UseParallelGC
  打开并行GC。
  5.GC线程数
  -XX:ParallelGCThreads=2
  减少垃圾收集线程,默认是和服务器CPU数相同。
  6.允许jconsole查看JVM状态
  -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=6000 -Dcom.sun.management.jmxremote.ssl=false
  port可以修改。
  7.禁止程序直接调用System.gc(),
  -XX:+DisableExplicitGC
  8.一个例子,把这行代码放入catalina.bat的第一行即可。
  JAVA_OPTS="-Xms2048m -Xmx2048m -XX:MaxPermSize=256m -XX:+UseParallelOldGC -XX:+UseParallelGC -XX:NewRatio=3 -XX:ParallelGCThreads=2 -XX:+DisableExplicitGC -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=6000 -Dcom.sun.management.jmxremote.ssl=false "
  参考:
  1.http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp Java HotSpot VM Options
  2.http://www.cjsdn.net/post/print?bid=62&id=196304 JVM参数调优实践
3.http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html TuningGarbage Collectionwith the 5.0 JavaTM Virtual Machine
  4.http://gocom.primeton.com/blog6857_30076.htm?PHPSESSID=%3COOM和JVM配置优化(二)
  5.http://java.sun.com/performance/reference/whitepapers/tuning.html
  6.http://hi.baidu.com/xiayingjie2008/blog/item/a439d5023fd2c3084afb512a.html jvm 参数调优(转)
页: [1]
查看完整版本: tomcat使用的JVM参数