java permgen space outOFMemory 总结

来源:互联网 发布:东南亚中国 知乎 编辑:程序博客网 时间:2024/06/05 23:39
 
java permgen space outOFMemory 总结
2008-05-28 17:47

通过以上三篇关于JVM性能调优的文章,总结如下:

JVM堆分为三个部分

(1) 新域:存储所有新成生的对象

(2) 旧域:新域中的对象,经过了一定次数的垃圾回收循环后,被移入旧域

(3)永久域:存储类和方法对象,从配置的角度看,这个域是独立的,不包括在JVM堆内。默认为4M。

所以如果你的WEB APP下都用了大量的第三方jar, 其大小超过了jvm 永久域(PermGen space)默认的大小(4M)那么就会产生permgen space outOf Memory。
所以可以对JVM中的参数进行配置来避免这个问题:
参数:-Xms 初始堆分配的大小
        
          -Xmx 堆分配的最大值
         -Xmn 新域的大小
         -XX:MaxNewSize : 新域的最大值
         -XX:MaxPermSize : 永久域的最大值

提示:Heap Size 最大不要超过可用物理内存的80%,一般的要将-Xms和-Xmx选项设置为相同,而-Xmn为1/4的-Xmx值。

如果发生了permgen space outOfMemory,解决办法:如果你的TOMCAT是安装半的可以进入注册表 把TOMCAT下的JAVA文件夹下名为Options的文件加上类似于如下的参数即可:-Xms256m -Xmx256m -XX:MaxNewSize=256m -XX:MaxPermSize=256m,也可以用以下方法; 如果为免安装版的修改TOMCAT_HOME/bin/catalina.bat(windows) 或TOMCAT_HOME/bin/catalina.sh(linux,unix),在文件里设置如下:

SET JAVA_OPTS=% JAVA_OPTS% -Xms256m -Xmx256m -XX:MaxNewSize=256m -XX:MaxPermSize=256m "

然后重启TOMCAT

Some Useful -XX Options


Option and Default ValueDescription-XX:-AllowUserSignalHandlersDo not complain if the application installs signal handlers. (Relevant to Solaris and Linux only.)-XX:AltStackSize=16384Alternate signal stack size (in Kbytes). (Relevant to Solaris only, removed from 5.0.)-XX:-DisableExplicitGCDisable calls to System.gc(), JVM still performs garbage collection when necessary.-XX:+FailOverToOldVerifierFail over to old verifier when the new type checker fails. (Introduced in 6.)-XX:+HandlePromotionFailureThe youngest generation collection does not require a guarantee of full promotion of all live objects. (Introduced in 1.4.2 update 11) [5.0 and earlier: false.]-XX:+MaxFDLimitBump the number of file descriptors to max. (Relevant to Solaris only.)-XX:PreBlockSpin=10Spin count variable for use with -XX:+UseSpinning. Controls the maximum spin iterations allowed before entering operating system thread synchronization code. (Introduced in 1.4.2.)-XX:-RelaxAccessControlCheckRelax the access control checks in the verifier. (Introduced in 6.)-XX:+ScavengeBeforeFullGCDo young generation GC prior to a full GC. (Introduced in 1.4.1.)-XX:+UseAltSigsUse alternate signals instead of SIGUSR1 and SIGUSR2 for VM internal signals. (Introduced in 1.3.1 update 9, 1.4.1. Relevant to Solaris only.)-XX:+UseBoundThreadsBind user level threads to kernel threads. (Relevant to Solaris only.)-XX:-UseConcMarkSweepGCUse concurrent mark-sweep collection for the old generation. (Introduced in 1.4.1)-XX:+UseGCOverheadLimitUse a policy that limits the proportion of the VM's time that is spent in GC before an OutOfMemory error is thrown. (Introduced in 6.)-XX:+UseLWPSynchronizationUse LWP-based instead of thread based synchronization. (Introduced in 1.4.0. Relevant to Solaris only.)-XX:-UseParallelGCUse parallel garbage collection for scavenges. (Introduced in 1.4.1)-XX:-UseParallelOldGCUse parallel garbage collection for the full collections. Enabling this option automatically sets -XX:+UseParallelGC. (Introduced in 5.0 update 6.)-XX:-UseSerialGCUse serial garbage collection. (Introduced in 5.0.)-XX:-UseSpinningEnable naive spinning on Java monitor before entering operating system thread synchronizaton code. (Relevant to 1.4.2 and 5.0 only.) [1.4.2, multi-processor Windows platforms: true]-XX:+UseTLABUse thread-local object allocation (Introduced in 1.4.0, known as UseTLE prior to that.) [1.4.2 and earlier, x86 or with -client: false]-XX:+UseSplitVerifierUse the new type checker with StackMapTable attributes. (Introduced in 5.0.)[5.0: false]-XX:+UseThreadPrioritiesUse native thread priorities.-XX:+UseVMInterruptibleIOThread interrupt before or with EINTR for I/O operations results in OS_INTRPT. (Introduced in 6. Relevant to Solaris only.)