我經常會這樣來設置服務器端的JVM:JAVA_OPTS="-server -Xms3000m -Xmx3000m -Xss512k"
-server:一定要作為第一個參數,在多個CPU時性能佳
-Xms:初始Heap大小,使用的最小內存
-Xmx:java heap最大值,使用的最大內存
??? 上面兩個值一般設置為同樣的大小。
-Xss:每個線程的Stack大小
-verbose:gc 現實垃圾收集信息
-Xloggc:gc.log 指定垃圾收集日志文件
剛剛了解到的一些參數(待實踐測試)
-Xmn:young generation的heap大小,一般設置為Xmx的3、4分之一
-XX:+UseParNewGC :縮短minor收集的時間
-XX:+UseConcMarkSweepGC :縮短major收集的時間
??? 提示:此選項在Heap Size 比較大而且Major收集時間較長的情況下使用更合適。
-server:一定要作為第一個參數,在多個CPU時性能佳
-Xms:初始Heap大小,使用的最小內存
-Xmx:java heap最大值,使用的最大內存
??? 上面兩個值一般設置為同樣的大小。
-Xss:每個線程的Stack大小
-verbose:gc 現實垃圾收集信息
-Xloggc:gc.log 指定垃圾收集日志文件
剛剛了解到的一些參數(待實踐測試)
-XX:+UseParNewGC :縮短minor收集的時間
-XX:+UseConcMarkSweepGC :縮短major收集的時間
??? 提示:此選項在Heap Size 比較大而且Major收集時間較長的情況下使用更合適。
Default max heap of Sun JDK version early than 1.5 is 64 MB, at 1.5 it can grow up to 1GB. Specifying -Xmx only has no side effects to -Xms. eg -Xmx800M the the process is still using a little memory while start up.
-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
-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.
我的配置,網站shedewang.com,72小時之內沒有任何停頓。但是還是要考慮到不同情況,多看看gc日志堆棧的變化,有問題用jstack,jmap等工具查看哪些地方出了問題,這樣可以更快的作出優化。
實踐是檢驗真理的唯一標準。