Tomcat – java.lang.OutOfMemoryError: PermGen space
来源:互联网 发布:尔雅网络课程刷课 编辑:程序博客网 时间:2024/05/21 21:46
Often time, Tomcat may hits the following java.lang.OutOfMemoryError: PermGen space
error.
java.lang.OutOfMemoryError: PermGen space at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:620) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
It’s usually happened after the Tomcat restarts a few times.
1. Solution
By default, Tomcat is assigned a very little PermGen memory for the running process. To fix it, increase the PermGen memory settings by using the following Java VM options.
-XX:PermSize<size> - Set initial PermGen Size.-XX:MaxPermSize<size> - Set the maximum PermGen Size.
In the next step, we will show you how to set the VM options in Tomcat, under Windows and Linux environment.
2. Windows
Tomcat is managed by this script file catalina.bat
, dive inside the script, you will find out that catalina.bat
always find and run the setenv.bat
file to set the environment variables.
//...rem Get standard environment variablesif not exist "%CATALINA_BASE%\bin\setenv.bat" goto checkSetenvHomecall "%CATALINA_BASE%\bin\setenv.bat"goto setenvDone:checkSetenvHomeif exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat":setenvDone//...
2.1 To set the environment variable on Windows, create a setenv.bat
manually, and put it into the ${tomcat-folder}\bin
folder.
set JAVA_OPTS=-Dfile.encoding=UTF-8 -Xms128m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=256m
P.S No double quotes, set JAVA_OPTS={value}.
2.2 Restart Tomcat, it will call the setenv.bat
file to set the environment variable automatically.
{$tomcat-folder}\bin\catalina.bat restart
3. Linux
On Linux, the process is same, just Tomcat is using catalina.sh
and setenv.sh
instead.
3.1 Find out where is catalina.sh
:
$ sudo find / -name "catalina.sh"Password:find: /dev/fd/3: Not a directoryfind: /dev/fd/4: Not a directory/Users/mkyong/Downloads/apache-tomcat-6.0.35/bin/catalina.sh
3.2 Review the catalina.sh
, script, it behaves like Windows, but use setenv.sh
instead.
//...# Ensure that any user defined CLASSPATH variables are not used on startup,# but allow them to be specified in setenv.sh, in rare case when it is needed.CLASSPATH=if [ -r "$CATALINA_BASE/bin/setenv.sh" ]; then . "$CATALINA_BASE/bin/setenv.sh"elif [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then . "$CATALINA_HOME/bin/setenv.sh"fi//...
3.3 Create a setenv.sh
manually, and put it into the ${tomcat-folder}\bin\
folder.
export JAVA_OPTS="-Dfile.encoding=UTF-8 -Xms128m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=256m"
P.S With double quotes, export JAVA_OPTS=”{value}”.
3.4 Restart Tomcat.
The heap size and non-heap size (perm gen) value is just an example, you should change the value accordingly to suit your project needs.
- Tomcat – java.lang.OutOfMemoryError: PermGen space
- Tomcat – java.lang.OutOfMemoryError: PermGen space
- Tomcat – Java.Lang.OutOfMemoryError: PermGen Space
- Tomcat – Java.Lang.OutOfMemoryError: PermGen Space
- Tomcat – java.lang.OutOfMemoryError: PermGen space
- Tomcat – Java.Lang.OutOfMemoryError: PermGen Space
- Tomcat – Java.Lang.OutOfMemoryError: PermGen Space
- tomcat 提示 java.lang.OutOfMemoryError: PermGen space
- Tomcat-----------------java.lang.OutOfMemoryError: PermGen space
- tomcat:java.lang.outofmemoryerror permgen space
- tomcat java.lang.OutOfMemoryError: PermGen space
- tomcat 7 java.lang.OutOfMemoryError: PermGen space
- Tomcat java.lang.OutOfMemoryError: PermGen space解决
- MyEclipse tomcat java.lang.OutOfMemoryError: PermGen space
- tomcat部署 java.lang.OutOfMemoryError: PermGen space
- tomcat:Java.Lang.OutOfMemoryError: PermGen Space
- tomcat内存java.lang.OutOfMemoryError: PermGen space
- tomcat:java.lang.outofmemoryerror permgen space
- ViewDragHelper的使用
- JAVA多态的实现原理(JVM实现方式)
- Oracle ora-01843错误解决思路
- query操作的加锁过程和时间统计
- C++第四次作业
- Tomcat – java.lang.OutOfMemoryError: PermGen space
- android parse init.rc
- Python一日一练10----快速排序
- Android Studio (二)——使用技巧
- markdown_语法
- Json的解析
- JavaScript的总结博客
- #!/bin/sh 和 #!/bin/bash 区别 2013年3月14日
- 史上最详细Android集成QQ,微信,微博分享(不用第三方)持续更新中