tomcat使用的JVM参数

转自http://blog.csdn.net/jackyyen/article/details/5298753

 

最近的项目遇到分配给JVM的内存不足的问题,解决的同时,发现一些有意思的参数,可以考虑今后使用并测试下。

1.分配给JVM内存,

这个基本上就是

-Xms999m 和 -Xmx999m,Xms是程序初始内存,Xmx是程序可用最大内存。

2.分配给Permanent Generation的内存,

-XX:MaxPermSize=256m

Size of the Permanent Generation.  [5.0 and newer: 64 bit VMs are scaled 30% larger; 1.4 amd64: 96m; 1.3.1 -client: 32m.]

3.new/old generation的比值

-XX:NewRatio=2

Ratio of new/old generation sizes. [Sparc -client: 8; x86 -server: 8; x86 -client: 12.]-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 -Dcom.sun.management.jmxremote.authenticate=false"

注意标红部分jdk8不支持

 

参考:

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 Tuning Garbage Collectionwith the 5.0 Java TM Virtual Machine

4.http://gocom.primeton.com/blog6857_30076.htm?PHPSESSID=%3C OOM和JVM配置优化(二)

5.http://java.sun.com/performance/reference/whitepapers/tuning.html

6.http://hi.baidu.com/xiayingjie2008/blog/item/a439d5023fd2c3084afb512a.html jvm 参数调优(转)

猜你喜欢

转载自ydlmlh.iteye.com/blog/1882640