java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20047152/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space
提问by SW Engineer
every body
每个身体
i got exception when i run server ,i think it's memory leaks!
运行服务器时出现异常,我认为是内存泄漏!
i tried many values of parameter JAVA_OPS and still got exception!!!
我尝试了参数 JAVA_OPS 的许多值,但仍然出现异常!!!
In console i got this exception you can see as below!
在控制台中,我得到了这个异常,你可以看到如下!
Nov 18, 2013 2:48:48 PM org.apache.catalina.startup.HostConfig deployDescriptors
SEVERE: Error waiting for multi-thread deployment of context descriptors to complete
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space
at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:578)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1401)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:317)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:347)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1140)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: PermGen space
Exception in thread "main" java.lang.OutOfMemoryError: PermGen space
采纳答案by Olaf Kock
It always makes sense to specify what the "many values" are that you've already tried.
指定您已经尝试过的“许多值”是什么总是有意义的。
First of all: They'd need to be JAVA_OPTS
, but that might also be a typo just in this question. However, it's even better to use CATALINA_OPTS
.
首先:他们需要是JAVA_OPTS
,但这也可能是这个问题中的一个错字。但是,使用CATALINA_OPTS
.
Most important, when there are PermGen errors, -Xmx
doesn't help at all. You want to set -XX:MaxPermSize=256m
(or some other amount of memory). You'll find a lot of information about this issue when you just google the error message - PermGen is a specific region of memory that the Sun/Oracle JVM uses. Increasing the available Heap memory doesn't help at all.
最重要的是,当存在永久代错误时,-Xmx
根本没有帮助。您想要设置-XX:MaxPermSize=256m
(或其他一些内存量)。当您在 google 上搜索错误消息时,您会发现很多有关此问题的信息 - PermGen 是 Sun/Oracle JVM 使用的特定内存区域。增加可用的堆内存根本没有帮助。
回答by blackpanther
I find that this also happens with GlassFish, another Java Application Server. Usually, we have to restart the Application Server to free all the memory and resources that the Application Server uses. Most Java Application Servers, like GlassFish and Tomcat, can be quite memory hungry. You may want to add the following line to your catalina.sh file (or other catalina config file) to change the JVM parameters and that could increase the memory allocation:
我发现另一个 Java 应用程序服务器 GlassFish 也会发生这种情况。通常,我们必须重新启动应用程序服务器才能释放应用程序服务器使用的所有内存和资源。大多数 Java 应用程序服务器,如 GlassFish 和 Tomcat,可能非常需要内存。您可能希望将以下行添加到您的 catalina.sh 文件(或其他 catalina 配置文件)以更改 JVM 参数,这可能会增加内存分配:
export CATALINA_OPTS="-Xms512M -Xmx1024M"
回答by Satheesh Cheveri
What is the point of increasing memory with out analyzing the cause. I would suggest try with some profiling tools(JProfiler, YourToolkKit) to catch the problem guy.
在不分析原因的情况下增加内存有什么意义。我建议尝试使用一些分析工具(JProfiler、YourToolkKit)来捕捉问题所在。
Once you have some idea about what is causing issue, you can work towards it ( for eg: Open connections, unclosed streams etc)
一旦您对导致问题的原因有了一些了解,您就可以着手解决问题(例如:打开的连接、未关闭的流等)
best of luck.
祝你好运。
回答by Abir Khan
In linux , create a setenv.sh file and keep the file inside tomcat/bin
folder.
Add below line in the file and save it.
在 linux 中,创建一个 setenv.sh 文件并将该文件保存在文件tomcat/bin
夹中。在文件中添加以下行并保存。
export CATALINA_OPTS="$CATALINA_OPTS -server -Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m"
export CATALINA_OPTS="$CATALINA_OPTS -server -Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m"
Now restart tomcat , you are ok to go..!!
现在重启 tomcat ,你就可以走了..!!
回答by Usman Yaqoob
You will have to set XX:MaxPermSize in your tomcat server VM argument as below:
您必须在您的 tomcat 服务器 VM 参数中设置 XX:MaxPermSize,如下所示:
Based on your memory on your local system you could modify:
根据您在本地系统上的内存,您可以修改:
Double click server go to open launch configuration
双击 server go 打开启动配置
In vm arguments Put this line
在 vm 参数中放置这一行
-XX:MaxPermSize=2048m
-XX:MaxPermSize=2048m
now restart tomcat
现在重启tomcat
回答by Sineth Lakshitha
In linux, Add following lines to catalina.sh
located in path_to_tomcat/bin.
在 linux 中,catalina.sh
将以下行添加到path_to_tomcat/bin 中。
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
After that, You should create setenv.sh
(if not exist in the bin)
if you are in path_to_tomcat/bin
之后,setenv.sh
如果您在 path_to_tomcat/bin中,则应该创建(如果 bin 中不存在)
vi ./setenv.sh
vi ./setenv.sh
and add follwing line
并添加以下行
export JAVA_OPTS="-Dfile.encoding=UTF-8 -Xms128m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=256m"
Now restart the tomcat your problem is over...
现在重启tomcat,你的问题就解决了...