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
.
We are using Struts2 as framework, Tomcat 6 as server and Openejb for the database connection.
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.
Here is the report of Memory Analyser :
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.
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.
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:
The cache of
ResourceEntry
for classes and resources we have loaded, keyed by resource name.
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.
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.