Recently, under the TOMCAT6, the simultaneous release of multiple apps (in fact, two apps, the two apps through the webservice to each other, the other three sockets to monitor), the system started no problem. The But system always throws java.lang.OutOfMemoryError:PermGen space when it is running.
According to previous experience, the-XSS parameters of Java, but increase to 16M, still as usual throw Exception. So, how.
Google later learned that the permanent heap overflow in the JVM. The root cause was the design of the Java Virtual machine, and the SUN JVM divided the memory into different areas, one of which was the Permenter area used to store a very much used class and class description. Sun was originally designed to assume that the area was fixed when the JVM was started, but he did not expect the current dynamics to be so widespread. And this area has a special garbage recovery mechanism, now the problem is to dynamically load the class to this area, the GC is simply not able to recycle. (This issue is hotly debated in spring's forum, because spring's use of cblib in AOP creates many classes dynamically.) And the bug was raised as early as 2003, and But Sun seems to have not solved the problem.
So, you can't recycle it to enlarge it. How to enlarge it.
-xx:maxnewsize=256m-xx:maxpermsize=256m
In addition: The full name of PermGen space PermGen spaces is permanent Generation, which refers to the permanent storage area of memory, which is mainly stored by the JVM class and meta information, Class is placed in the PermGen space when it is loader, unlike the heap region where the class instance (Instance) is stored, the GC (garbage Collection) does not clean up permgen spaces during the main program run. So if you have a lot of classes in your application, there is a good chance of permgen space errors, which are common when Web servers pre compile the JSP. If your web app uses a large number of third-party jars that are larger than the JVM default size (4M), this error message is generated.
Tomcat Modify this issue:
Under Windows, in the file {Tomcat_home}/bin/catalina.bat
The following settings can be added at the beginning of the file:
Set java_opts=-xms512m-xmx512m-xss1024k-xx:maxnewsize=256m-xx:maxpermsize=256m
Unix/linux, in front of the file {tomcat_home}/bin/catalina.sh, you can add the following settings:
java_opts= '-xms512m-xmx512m-xss1024k-xx:maxnewsize=256m-xx:maxpermsize=256m '
Interpretation of the parameters:
-XMS: The size of the memory stack when the program is initialized.
-XMX: The maximum amount of memory that an application (not a JVM) can use, which should not be set too large to exceed machine memory. Otherwise, Tomcat will not start. This value can be set to be the same as-xmx to avoid the JVM reallocating memory after each garbage collection completes.
-XSS: Sets the stack size for each thread. After JDK5.0, each thread stack size is 1M.
-xx:maxpermsize: Set Persistent generation size
-xx:newsize: Set Young generation size
This article is related to the Java Virtual Machine and garbage collection mechanism issues, not to do in detail, please consult Google directly.
Note: This article directly from my other blog to move.