After deploying the project with SSH, the OutOfMemoryError PermGen space system error will appear after several deployments, and by checking the data online, it is not the problem of Tomcat, and the JVM design itself is a flaw, the JVM has divided the memory into different zones, The full name of PermGen space is permanent Generation space, which refers to the permanent storage area of memory, which is stored in this area when the class is loaded. Sun was designed to think the area was fixed when the JVM started, but he didn't expect it to be used so extensively. And this area has a special garbage recovery mechanism, now the problem is that the dynamic loading class to this area, the GC has no way to recycle!
I did not think that this problem has not been solved, some of the best solution is not to use the JDK, using BEA jrokit, of course, now Oracle,bea,su has become a family, I think this problem should be faster and better solutions.
Ok or talk about how to solve the problem, online a large number of data said in the Tomcat set: Set java_opts=-xms64m-xmx512m, but after my test, not a bit of a role, detailed look at the JVM memory allocation mechanism to know,- XMS and--xmx are resizing Java heap space (that is, heap memory), where objects are stored in the Ava Heap space area, and the GC collects this area.
If the exception type that appears is: Outofmemoryerror:java heap space, set java_opts=-xms64m-xmx512m.
If the exception type that appears is: OutOfMemoryError PermGen space, set java_opts=-xms128m-xmx512m-xx:permsize=128m-xx:maxpermsize= 256m
There are two common ways to set this up:
If you start Tomcat in the development environment, take eclipse as an example: select Window->preferences->myeclipse-servers-tomcat->jdk in the right-hand box optional Java VM Arguments add:-xms128m-xmx512m-xx:permsize=128m-xx:permsize=256m
If you start Tomcat independently, modify the Tomcat/bin/catalina.bat file to find the set java_opts, and then change the line to:
Set java_opts=-xms128m-xmx512m-xx:permsize=128m-xx:maxpermsize=256m, note:-xms+x:permsize cannot be larger than the maximum JVM size supported by the system. Size according to your own memory size adjustment bar.
Workarounds for SSH deployment to tomcat memory overflow-outofmemoryerror