1. Problem Scenario:
When you deploy a project, deploy two apps to the same Tomcat, and the console appears Java.lang.OutOfmemoryError:PermGen Space error when you start the service through Startup.bat
Server environment:
System version: Windows Server R2
Installed Memory: 64GB
Processor: 8 cores (specific models are not recorded)
2. Solution:
PermGen space: The full name is permanent Generation space, refers to the memory of the permanent storage area, this memory is mainly stored by the JVM class and meta information, class is load will be placed in the PermGen Space , which differs from the heap area where the class instance (Instance) is stored, the GC (garbage Collection) does not clean up permgen space during the main program run time, so if you have many classes in your application, you are likely to appear PermGen Space error, this error is common when the Web server pre-compile the JSP. If your web app uses a large number of third-party jars that are larger than the JVM's default size (4M), the error message appears.
Proven Workaround: Modify the contents of the Catalina.bat file, add the settings for the PermSize parameter, depending on the case:
Before modification:
REM -----Execute The requested Command--------------------------------------- Set java_opts=%java_opts%-dfile.encoding= "UTF-8"-dsun.jnu.encoding= "UTF8"-ddefault.client.encoding= "UTF-8"- duser.language=Zhset java_opts=%java_opts%-server-xms1024m-xmx1024m-xx: maxnewsize= 512m
After modification:
rem -----Execute the requested Command---- ----------------------------------- set java_opts=%java_opts%- dfile.encoding= "UTF-8"-dsun.jnu.encoding= "UTF8"-ddefault.client.encoding= "UTF-8"-duser.language=zh set java_opts=%java_opts%-server-xms1024m-xmx1024m-xx:maxnewsize =512m-xx:P ermsize =256m-xx :maxpermsize =512m
Restart Tomccat again and start normally.
Below is a workaround for other startup methods and environments on the network for future reference
1. Eclipse Development Environment
Modify the Eclipse.ini file
-vmargs
-dosgi.requiredjavaversion=1.5
-xms128m
-xmx512m
-xx:permsize=64m
-xx:maxpermsize=128m
2. Windows Service mode starts Tomcat
Modify the Registration Form
3. Linux System
Modify catalina.sh:
Java_opts= "-xms1024m-xmx2048m-xx:permsize=256m-xx:maxpermsize=512m"
Windows system Bat mode starts tomcat with Java.lang.OutOfmemoryError:PermGen Space error