Reason : The full name of PermGen space is Permanent Generation space, which refers to the permanent storage area of memory.
This memory is mainly used by JVM to store Class and Meta information. When Class is loaded by Loader, it will be placed
in PermGen space. The Heap area of the class instance (Instance) is different, and the GC (Garbage Collection) will not
clean up the PermGen space during the running of the main program, so if your application has a lot of CLASS, it is likely to appear PermGen
space error, this kind of error It is common when the web server pre-compiles the JSP. If your WEB APP uses a large
number of third-party jars, the size of which exceeds the default size of jvm (4M), then this error message will be generated.
Here are the various claims on the Internet:
But the question is why these ace open source have the same problem, so is it a more basic reason? tomcat answers this vaguely in the Q&A, we know the question, but the question arises from a more fundamental question.
So someone checked the more basic JVM and found the crux of the problem. It turns out that SUN's JVM divides the memory into different areas, one of which is the permenter area, which is used to store the classes and class descriptions that are used a lot. Originally, SUN thought that this area was fixed when the JVM was started, but he did not expect that the dynamic would be used so widely now. And this area has a special garbage collection mechanism. The problem now is that after dynamically loading classes into this area, gc can't collect them at all! In 2003, a bug was reported to sun, but until now, this bug has not been closed! Someone added a comment to this bug: "A bug this critical is open since 2003? Absolutely shameful."
(3) It's usually happened when the Tomcat start and stop few times. It's just funny, however you can fine tune it with some minor changes in the Tomcat configuration setting. By default, Tomcat assigned very little memory for the running process, you should increase the memory by make change in catalina.sh or catalina.bat file.
Workaround : Manually set the MaxPermSize size
Set parameters -Xms256m -Xmx512m -XX:MaxNewSize=256m -XX:MaxPermSize=256m
In Tomcat, modify TOMCAT_HOME/bin/catalina.sh (start.sh under linux system will call it to start tomcat, under windows call catalina.bat, the modification is similar)
在文件头部注释后加入
JAVA_OPTS='-Xms256m -Xmx512m -XX:MaxNewSize=256m -XX:MaxPermSize=256m'
如果tomcat运行多个系统,将相同的第三方jar文件移置到tomcat/shared/lib目录下,这样可以达到减少
jar 文档重复占用内存的目的。