aspose file tools*
The moose likes Tomcat and the fly likes URGENT: Java Tomcat - Memory leak issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "URGENT: Java Tomcat - Memory leak issue" Watch "URGENT: Java Tomcat - Memory leak issue" New topic
Author

URGENT: Java Tomcat - Memory leak issue

Lakshmi Ramachandran
Greenhorn

Joined: Jun 26, 2001
Posts: 26
Hi folks,

In my current project, We are experiencing various errors and system instability with Tomcat Server.

The error presents itself to the web client user as an Out of Memory exception when we are performing web searches and retrieving content. "java.lang.OutOfMemoryError"

When the errors begin to occur, it is found that restarting the Tomcat server seems to clear up the problem for a short period of time.

We increased the heap size (default size X 4) request but were receiving the Out of Memory errors so now have decreased to 2X's the default size. This seemed to decrease the frequency of the errors although they are still occurring. Default size is 256.

The Tomcat logs are filled with the following error:

2004-06-03 07:22:35 StandardWrapperValve[fdk-request]: Servlet.service() for servlet fdk-request threw exception
java.lang.NullPointerException
at com.fcg.dmsl.fdk.web.servlet.RequestProcessorServlet.service(RequestProcessorServlet.java:116)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:479

As part of the resolution process, I increased the HEAP size, but this did not solve the problem. This seems to be a memory leak and mainly due to some code which might be hanging onto object references and the garbage collector can't do its job.

Please let me know the remedy for this .
Also, please tell what are the other possible causes & perhaps remedies too.

Looking forward to early response.

Thanks in advance!
Vijayendra V Rao
Ranch Hand

Joined: Jul 04, 2004
Posts: 195
Hi,

Just check if any part of your code is creating Objects in a loop.


Vijayendra <br /> <br />"The harder you train in peace, the lesser you bleed in war"
Vijayendra V Rao
Ranch Hand

Joined: Jul 04, 2004
Posts: 195
You can use a great tool called JProbe to detect the exact portion(s) of your code thats causing memory leaks.
Lakshmi Ramachandran
Greenhorn

Joined: Jun 26, 2001
Posts: 26
Hi Vijayendra,

Thanks for your response.

I have done the code walkthru and did not find any objects being created in the loop. We performed code optimization and removed such discrepancies during the process.

Increasing the Heap size also did not help.

I shall use the JProbe tool, as u have suggested, and try to figure the problem. Thanks!
Vijayendra V Rao
Ranch Hand

Joined: Jul 04, 2004
Posts: 195
Sure!

The JProbe tool is very easy to use and it will show you the precise memory usage for each and every line of your code. You can easily catch the culprit!
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
We're encountering a similar problem in a large servlet/JSP project.
We've tracked it down to a leak in the JSP compiler in Tomcat 4.
During development of JSPs (when a lot of compiles happen of course) the server runs out of memory regularly.
When running on a test system with precompiled JSPs there is no problem.


42
Lakshmi Ramachandran
Greenhorn

Joined: Jun 26, 2001
Posts: 26
Oic, then Jeroen, how did u resolve the problem?
Could u please give some insight?
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
We "solved" the problem by restarting the development server whenever it happens and monitoring the test server (where it doesn't happen so far).

Tomcat 5 seems to have solved it as well, but I've not yet done enough testing on it to be certain.

P.S. once all JSPs are compiled on a production server you'll never call the compiler again unless you replace a JSP with a new version (or throw away the generated classfiles and sources).
[ August 02, 2004: Message edited by: Jeroen Wenting ]
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

moving this to the Tomcat forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URGENT: Java Tomcat - Memory leak issue
 
Similar Threads
deployment problem
session
Problem compiling JSPs on Tomcat
How do i correct this error
HTTP Status 500