简体   繁体   English

Java - OutOfMemoryError:PermGen空间

[英]Java - OutOfMemoryError: PermGen space

I'm currently developing a tool allowing me to get statistics from anyware simply by going on a website I also created. 我正在开发一个工具,允许我通过访问我也创建的网站从任何软件获取统计数据。

For those who don't know, Birt is a reporting tool, and an eclipse plugin. 对于那些不知道的人,Birt是一个报告工具和一个eclipse插件。

My problem is the following : 我的问题如下:

I installed tomcat on the server hosting my website, and installed the Birt ReportEngine on it, and on my website, I call the online viewer to get my reports. 我在托管我网站的服务器上安装了tomcat,并在其上安装了Birt ReportEngine,在我的网站上,我呼叫在线查看器来获取我的报告。

The problem is that since yesterday, when I launch a report, I have this error : 问题是,从昨天起,当我发布报告时,我有这样的错误:

javax.servlet.ServletException: L'exécution de la servlet a lancé une exception
    org.eclipse.birt.report.filter.ViewerFilter.doFilter(ViewerFilter.java:68)

Caused by : 引起:

java.lang.OutOfMemoryError: PermGen space

I don't really know which config file to modify to avoid this error. 我真的不知道要修改哪个配置文件以避免此错误。 I found some examples online that tell to modify the eclipse.ini file, but as for mty website, I don't use eclipse, I didn't found any usefull post. 我在网上发现了一些修改eclipse.ini文件的例子,但对于mty网站,我没有使用eclipse,我没有找到任何有用的帖子。

Can someone help me please ? 有谁可以帮助我吗 ?

Thanks 谢谢

As said by Thomas, the parameter to set is -XX:MaxPermSize . 正如Thomas所说,要设置的参数是-XX:MaxPermSize One way of setting this parameter for Tomcat is to use the CATALINA_OPTS environment variable. 为Tomcat设置此参数的一种方法是使用CATALINA_OPTS环境变量。

For Windows : 对于Windows:

set CATALINA_OPTS=-Xms512m -Xmx512m -XX:MaxPermSize=256m

For Linux (bash) : 对于Linux(bash):

export CATALINA_OPTS="-Xms512m -Xmx512m -XX:MaxPermSize=256m"

Check the startup.bat and catalina.bat or startup.sh and catalina.sh files in your tomcat/bin directory and add the above commands there. 检查tomcat / bin目录中的startup.batcatalina.batstartup.shcatalina.sh文件,并在其中添加上述命令。

(The Xmx and Xms parameters set the minimum and maximum size for the Java heap - where objects are stored. This is not the problem you have but I included them for the sake of completeness.) (Xmx和Xms参数设置Java堆的最小和最大大小 - 存储对象的位置。这不是您遇到的问题,但为了完整起见,我将它们包括在内。)

You need no add the following line to eclipse.ini 您无需在eclipse.ini中添加以下行

-XX:MaxPermSize=128m

If the problem occurs again try to increase the value. 如果再次出现问题,请尝试增加该值。 You can also add the following optional lines: 您还可以添加以下可选行:

-XX:+UseConcMarkSweepGC
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled
-XX:+UseParNewGC 

This changes the Garbage Collector of the JVM to a more optimized one, and can also improve the performance and memory usage. 这会将JVM的垃圾收集器更改为更优化的垃圾收集器,还可以提高性能和内存使用率。

You may also want to tweak the values of the -Xmx and Xms options. 您可能还想调整-XmxXms选项的值。 Try small increases (same to the -XX:MaxPermSize ) as this will increase the memory footprint of your JVM. 尝试小幅增加(与-XX:MaxPermSize相同),因为这会增加JVM的内存占用量。

For a more explained details see here: http://www.eclipsezone.com/eclipse/forums/t61618.html 有关更详细的详细信息,请参阅此处: http//www.eclipsezone.com/eclipse/forums/t61618.html

For a complete list of the JVM parameters and options: http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html 有关JVM参数和选项的完整列表, 请访问http//www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

Use that JVM option: -XX:MaxPermSize=256m (of course you are free to choose the amount of memory, but IIRC the default would be 64m so you'd need to increase that). 使用该JVM选项: -XX:MaxPermSize=256m (当然您可以自由选择内存量,但IIRC默认为64m,因此您需要增加内存量)。 - Note that this is for Oracle's JVM (formerly SUN's :) ) , other JVM's might have different options. - 请注意,这是针对Oracle的JVM(以前称为SUN的:)),其他JVM可能有不同的选项。

Other than that, try not hot deploying too much, since that might also increase the PermGen space usage (JBoss which includes Tomcat as has that problem, but I'm not sure whether that is true for a standalone Tomcat). 除此之外,尝试不要热部署太多,因为这也可能会增加PermGen空间使用量(包括Tomcat的JBoss就像这个问题一样,但我不确定对于独立的Tomcat是否也是如此)。

This can be solved by allocating more heap memory. 这可以通过分配更多堆内存来解决。 this can be done as: steps: double click on your eclipse server->open launch configuration->Arguments->paste this line in vm arguments text area:- 这可以这样做:步骤:双击您的eclipse服务器 - >打开启动配置 - >参数 - >将此行粘贴到vm参数文本区域: -

-XX:MaxPermSize=512M -Xmx1024M This will solve your outofmemory error. -XX:MaxPermSize = 512M -Xmx1024M这将解决您的outofmemory错误。

I added the below line line to eclipse.ini and working fine for me. 我将下面的行行添加到eclipse.ini并为我工作正常。

-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256m
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m
-XX:MaxPermSize=256m

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM