当你启动Tomcat的时候,报错内存不足.
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 176160768 bytes for committing reserved memory.
# An error report file with more information is saved as:
$ sudo find / -name "catalina.sh"
Password:
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/Users/zhang/Downloads/apache-tomcat-6.0.35/bin/catalina.sh
第一种方式:
直接在里面加入一行 :
JAVA_OPTS="-server -Xms100m -Xmx1024m -XX:PermSize=100m -XX:MaxPermSize=1024m"
注意:数字要一一对应,单位是M兆
第二种方式:
catalina.sh有以下代码:注意:(setenv.sh)
//...
# 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
//...
在当前目录下(/Users/zhang/Downloads/apache-tomcat-6.0.35/bin/)创建setenv.sh文件,写入
【下面的大小根据项目更改】
JAVA_OPTS="-server -Xms100m -Xmx1024m -XX:PermSize=100m -XX:MaxPermSize=1024m"
-XX:PermSize<size> - Set initial PermGen Size.
-XX:MaxPermSize<size> - Set the maximum PermGen Size.
重启tomcat