Linux下启动tomcat报java.lang.OutOfMemoryError: PermGen space

一、错误信息

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Exception in thread "main" java.lang.OutOfMemoryError: PermGen space
    at java.lang.Throwable.getStackTraceElement(Native Method)
    at java.lang.Throwable.getOurStackTrace(Throwable.java:591)
    at java.lang.Throwable.printStackTraceAsCause(Throwable.java:481)
    at java.lang.Throwable.printStackTrace(Throwable.java:468)
    at java.lang.Throwable.printStackTrace(Throwable.java:451)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:421)
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0" java.lang.OutOfMemoryError: PermGen space
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Timer-1" java.lang.OutOfMemoryError: PermGen space
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Timer-0" java.lang.OutOfMemoryError: PermGen space



二、解决方案

修改tomcat目录下面:bin/catalina.sh文件。

Linux下启动tomcat报java.lang.OutOfMemoryError: PermGen space

在图中的红框部分,添加如图代码。然后重新启动即可。

代码源码:

JAVA_OPTS="-Xms256m -Xmx512m -Xss1024K -XX:PermSize=128m -XX:MaxPermSize=256m"

尽量在Linux环境上修改。

三、部分操作的Linux命令

[[email protected] Boco]$ cd apache-tomcat-inas/bin/

[[email protected] bin]$ vim catalina.sh

Linux下启动tomcat报java.lang.OutOfMemoryError: PermGen space