Write Struts2 program Run when this problem occurs, now do the following two attempts, currently do not know whether it will continue to occur:
Try 1:
The full name of PermGen space is permanent Generation space, which refers to the permanent storage area of memory, which is used to store class and meta information, and class is placed in the PermGen space area when it is loaded. Unlike the heap area where the instance is stored, GC (garbage Collection) does not clean up permgen space during the main program run time, so if your app will load a lot of class, PermGen space error is likely to occur .
The reason for this problem is that the custom ClassLoader repeatedly loads the same jar many times, so as long as you avoid reloading the same jar again, you can solve the problem.
So the possible reasons are:
Too many classes are loaded
Too many jars are loaded
Too many jars loaded repeatedly
The specific solution:
1. Manually set the size of the MaxPermSize
Modify the Tomcat_home/bin/catalina.bat (Linux for catalina.sh) file,
Add this line to the echo "using Catalina_base: $CATALINA _base":
Set java_opts=%java_opts%-server-xx:permsize=128m-xx:maxpermsize=512m
Catalina.sh modified as follows:
java_opts= "$JAVA _opts"-server-xx:permsize=128m-xx:maxsize=512m
2. Modify the contents of the Tomcat_home/bin/catalina.bat file: Add after%_execjava%%java_opts%:
-xms=256m-xmx512m
Note that there are spaces before and after.
For example:%_execjava%%java_opts%-xms=256m-xmx512m (space), the following content is unchanged
3. Consider copying the same third-party jar files to the Tomcat/shared/lib directory, which can reduce the memory consumption of the jar files.
Mode 2:
Modify the MyEclipse as follows:
1. Window-->preferences...-->myeclipse-->application Servers-->tomcat,
2. Select the version of Tomcat you installed, select the following JDK, on the right
Optional Java VM arguments text box, enter:
-xmx256m-xms256m-xx:maxpermsize=256m
Now just record these two methods, specifically to verify.
Some attempts to java.lang.OutOfMemoryError:PermGen space