简体   繁体   English

Eclipse Memory Analyzer:java.lang.OutOfMemoryError:Java堆空间

[英]Eclipse Memory Analyser : java.lang.OutOfMemoryError: Java heap space

I'm having a problem with my application. 我的申请有问题。 When i try to open a page, the application raise an error of java.lang.OutOfMemoryError: Java heap space . 当我尝试打开页面时,应用程序引发了java.lang.OutOfMemoryError: Java heap space的错误。

We are using Struts2 as framework, Tomcat 6 as server and Openejb for the database connection. 我们使用Struts2作为框架,Tomcat 6作为服务器,使用Openejb作为数据库连接。

I tried to find why it's going out of memory with the Eclipse extension Memory Analyser but I have to say that it's not easy to understand. 我试图用Eclipse扩展内存分析器找出它为什么内存不足但我不得不说它不容易理解。

Here is the report of Memory Analyser : 以下是Memory Analyzer的报告:

顶级消费者描述累积点的最短路径统治者树中的累积对象

I'm not really sure about what raise this error but is it possible that the databases connection are not closed and then the map that contains this connection is becoming to big for the JVM. 我不确定是什么引发了这个错误但是数据库连接可能没有关闭,然后包含这个连接的地图对JVM来说变得很大。

I resolve the problem by giving more memory space to the JVM but i'm not sure it's the good way to solve this problem. 我通过为JVM提供更多内存空间来解决问题,但我不确定这是解决此问题的好方法。

Can anyone help me? 谁能帮我?

Thanks 谢谢

According to your snapshots, your problem comes from the field resourceEntries of the WebappClassLoader which is according to the javadoc: 根据您的快照,您的问题来自WebappClassLoader的字段resourceEntries ,它是根据javadoc:

The cache of ResourceEntry for classes and resources we have loaded, keyed by resource name. 我们加载的类和资源的ResourceEntry缓存,由资源名称键入。

In other words, it is a cache that will store all the meta information of all the resource files and classes that are loaded through the ClassLoader of your web application in order to avoid scanning the whole classpath at each call as it is potentially very slow especailly when you have a lot of jar files. 换句话说,它是一个缓存,它将存储通过Web应用程序的ClassLoader加载的所有资源文件和类的所有元信息,以避免在每次调用时扫描整个类路径,因为它可能非常慢当你有很多jar文件。

As far as I can see from the source code , for me there is no much you can do to workaround it except increasing your heap size as you already did. 据我所知,从源代码中可以看出,除了增加堆大小之外,没有太多可以解决的问题。

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

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