Tomcat – java.lang.OutOfMemoryError: PermGen space
2016-04-08 11:31
471 查看
Often time, Tomcat may hits the following
Java
It’s usually happened after the Tomcat restarts a few times.
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.
Bash
In the next step, we will show you how to set the VM options in Tomcat, under Windows and Linux environment.
Tomcat is managed by this script file
out that
to set the environment variables.
{$tomcat-folder}\bin\catalina.bat
Bash
2.1 To set the environment variable on Windows, create a
it into the
${tomcat-folder}\bin\setenv.bat
Bash
P.S No double quotes, set JAVA_OPTS={value}.
2.2 Restart Tomcat, it will call the
Bash
On Linux, the process is same, just Tomcat is using
3.1 Find out where is
catalina.sh
Bash
3.2 Review the
Bash
3.3 Create a
${tomcat-folder}\bin\setenv.sh
Bash
P.S With double quotes, export JAVA_OPTS=”{value}”.
3.4 Restart Tomcat.
Note
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.
java.lang.OutOfMemoryError: PermGen spaceerror.
Java
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.Bash
-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.batalways find and run the
setenv.batfile
to set the environment variables.
{$tomcat-folder}\bin\catalina.bat
Bash
//... rem Get standard environment variables if not exist "%CATALINA_BASE%\bin\setenv.bat" goto checkSetenvHome call "%CATALINA_BASE%\bin\setenv.bat" goto setenvDone :checkSetenvHome if 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.batmanually, and put
it into the
${tomcat-folder}\binfolder.
${tomcat-folder}\bin\setenv.bat
Bash
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.batfile to set the environment variable automatically.
Bash
{$tomcat-folder}\bin\catalina.bat restart
3. Linux
On Linux, the process is same, just Tomcat is using catalina.shand
setenv.shinstead.
3.1 Find out where is
catalina.sh:
catalina.sh
Bash
$ sudo find / -name "catalina.sh" Password: find: /dev/fd/3: Not a directory find: /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.shinstead.
Bash
//... # 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.shmanually, and put it into the
${tomcat-folder}\bin\folder.
${tomcat-folder}\bin\setenv.sh
Bash
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.
Note
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
- sevlert配置错误
- 观察者设计模式
- CXF+Spring+Tomcat简明示例
- 强制关闭tomcat sh脚本
- 【solr】 solr 5.4.1 和tomcat 基础环境搭建
- Description Resource Path Location Type Target runtime apache-tomcat-8.0.30 is not defined.
- linux 重启tomcat 实现自动化部署的一步
- 负载均衡与集群之apache+tomcat
- tomcat 绿色版的配置
- tomcat 中文乱码最简单处理方式
- Server Tomcat v7.0 Server at localhost failed to start.
- windows tomcat 优化
- 安装tomcat时出错:failed to install tomcat7 service问题的解决方法
- 【坑】tomcat中上传的图片文件无故消失
- Apache/Tomcat/JBOSS/Nginx区别
- tomcat中一个ip绑定多个域名
- Intellij IDEA 14远程调试Tomcat6
- centos6.5(阿里云)安装jdk,tomcat
- tomcat运行一段时间后,org.apache.jk.common.ChannelSock报错java.lang.IndexOutOfBoundsExcept