• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

URGENT: Java Tomcat - Memory leak issue

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Just check if any part of your code is creating Objects in a loop.
 
Vijayendra V Rao
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use a great tool called JProbe to detect the exact portion(s) of your code thats causing memory leaks.
 
Lakshmi Ramachandran
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Lakshmi Ramachandran
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oic, then Jeroen, how did u resolve the problem?
Could u please give some insight?
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
moving this to the Tomcat forum.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic