您的位置:首页 > 运维架构 > Tomcat

tomcat内存设置及jvm参数调优

2014-03-22 20:43 921 查看
设置tomcat的内存

1、修改 start.bat 中的

call "%EXECUTABLE%" start %CMD_LINE_ARGS%

为 call "%EXECUTABLE%" run %CMD_LINE_ARGS% 

2、 catalina.bat 首行加入

set JAVA_OPTS=-server -Xms512m -Xmx512m -XX:NewSize=64m -XX:MaxNewSize=512m -XX:PermSize=256m 

-XX:MaxPermSize=256m -XX:+UseParallelGC -XX:ParallelGCThreads=2

-server 以server的模式启动

-Xms   初始化堆内存大小(initial heap size)

-Xmx   最大堆内存大小(maximum heap size)

-XX:NewSize   新生代内存大小

-XX:MaxNewSize 最大新生代内存大小

-XX:PermSize   持久带内存初始化大小

-XX:MaxPermSize持久带内存最大大小

下面三个图很好的阐述了堆内存的分布: 新生代eden (young)   老年代tenure(old)  持久代(perm) 分布示意图如下:



 





 调优的参数:
 
Option and Default ValueDescription
-XX:+AggressiveOptsTurn on point performance compiler optimizations that are expected to be default in upcoming releases. (Introduced in 5.0 update 6.)
-XX:CompileThreshold=10000Number of method invocations/branches before compiling [-client: 1,500]
-XX:LargePageSizeInBytes=4mSets the large page size used for the Java heap. (Introduced in 1.4.0 update 1.) [amd64: 2m.]
-XX:MaxHeapFreeRatio=70Maximum percentage of heap free after GC to avoid shrinking.
-XX:MaxNewSize=sizeMaximum size of new generation (in bytes). Since 1.4, MaxNewSize is computed as a function of NewRatio. [1.3.1 Sparc: 32m; 1.3.1 x86: 2.5m.]
-XX:MaxPermSize=64mSize of the Permanent Generation.  [5.0 and newer: 64 bit VMs are scaled 30% larger; 1.4 amd64: 96m; 1.3.1 -client: 32m.]
-XX:MinHeapFreeRatio=40Minimum percentage of heap free after GC to avoid expansion.
-XX:NewRatio=2Ratio of new/old generation sizes. [Sparc -client: 8; x86 -server: 8; x86 -client: 12.]-client: 4 (1.3) 8 (1.3.1+), x86: 12]
-XX:NewSize=2mDefault size of new generation (in bytes) [5.0 and newer: 64 bit VMs are scaled 30% larger; x86: 1m; x86, 5.0 and older: 640k]
-XX:ReservedCodeCacheSize=32mReserved code cache size (in bytes) - maximum code cache size. [Solaris 64-bit, amd64, and -server x86: 48m; in 1.5.0_06 and earlier, Solaris 64-bit and amd64: 1024m.]
-XX:SurvivorRatio=8Ratio of eden/survivor space size [Solaris amd64: 6; Sparc in 1.3.1: 25; other Solaris platforms in 5.0 and earlier: 32]
-XX:TargetSurvivorRatio=50Desired percentage of survivor space used after scavenge.
-XX:ThreadStackSize=512Thread Stack Size (in Kbytes). (0 means use default stack size) [Sparc: 512; Solaris x86: 320 (was 256 prior in 5.0 and earlier); Sparc 64 bit: 1024; Linux amd64: 1024 (was 0 in 5.0 and earlier); all others 0.]
-XX:+UseBiasedLockingEnable biased locking. For more details, see this tuning
example. (Introduced in 5.0 update 6.) [5.0: false]
-XX:+UseFastAccessorMethodsUse optimized versions of Get<Primitive>Field.
-XX:-UseISMUse Intimate Shared Memory. [Not accepted for non-Solaris platforms.] For details, see Intimate
Shared Memory.
-XX:+UseLargePagesUse large page memory. (Introduced in 5.0 update 5.) For details, see Java
Support for Large Memory Pages.
-XX:+UseMPSSUse Multiple Page Size Support w/4mb pages for the heap. Do not use with ISM as this replaces the need for ISM. (Introduced in 1.4.0 update 1, Relevant to Solaris 9 and newer.) [1.4.1 and earlier: false]
-XX:+UseStringCacheEnables caching of commonly allocated strings.

 
-XX:AllocatePrefetchLines=1Number of cache lines to load after the last object allocation using prefetch instructions generated in JIT compiled code. Default values are 1 if the last allocated object was an instance and 3 if it was an array. 

 
-XX:AllocatePrefetchStyle=1Generated code style for prefetch instructions.

0 - no prefetch instructions are generate*d*,

1 - execute prefetch instructions after each allocation,

2 - use TLAB allocation watermark pointer to gate when prefetch instructions are executed.

 
-XX:+UseCompressedStringsUse a byte[] for Strings which can be represented as pure ASCII. (Introduced in Java 6 Update 21 Performance Release) 

 
-XX:+OptimizeStringConcatOptimize String concatenation operations where possible. (Introduced in Java 6 Update 20) 

 
相关参考文档:

http://www.oracle.com/technetwork/java/javase/tech/largememory-jsp-137182.html 

http://docs.oracle.com/javase/6/docs/technotes/tools/windows/java.html
http://docs.oracle.com/javase/6/docs/technotes/guides/vm/gc-ergonomics.html
http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: