1

This problem happens when my web application runs between 40 minutes to an hour and my application web doesn't work, the browser wait a response from server, i dont know if it is not by any error in the programming that i doing or a bug in tomcat or bug in jvm.

and this is the exception:

    Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" 
    Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]"
vrvictor
  • 95
  • 15
  • Assuming you're using a production tomcat, I think it is safe to say there is a bug in your code. – Elliott Frisch Jan 08 '14 at 19:44
  • 1
    OutOfMemoryErrors don't happen for nothing, and Tomcat is used by thousands of people. The problem is probably in your code, or caused by a non appropriate configuration. – JB Nizet Jan 08 '14 at 19:44
  • This is going to be difficult for someone to help you out as it could be several things. Here are a few things to check: 1) Increase memory of your tomcat server if you are really using that much memory; 2) turn on debug of tomcat and see if resources are not being released. – wxkevin Jan 08 '14 at 19:45

4 Answers4

3

It's very probably that you have a memory leak in your application. You have to investigate which objects are eating you memory. To do this, you have to:

  1. Get tomcat pid (use "jps -l" or "ps ux "grep java")
  2. Use jmap to show objects histogram: "jmap -histo:live | head -n20"

Then you will see where the problem is. It will also be very helpful if you will check your memory settings? Maybe your application just needs more memory?

Jakub Kubrynski
  • 13,724
  • 6
  • 60
  • 85
1

It's extremely likely to be your code. Tomcat and the JVM don't go OOM on their own nowadays. You are either leaking memory, or simply your app requires too much memory for your current configuration.

Will Hartung
  • 115,893
  • 19
  • 128
  • 203
0

Since you say that it appears after a long time (over 40 mins) it is likely to be caused by memory leaks (you probably continuously take memory for objects and keep it in use so that the garbage collector can do nothing about it).

Bogdan
  • 51
  • 4
0

This is not a trivial problem, the best way to fight it is to try some post-mortem analysis of your object pool after the problem rises again. I would use jconsole (it is for free and included in every modern JDK), and there are other tools.

Once you have that analysis, there are 2 options:

  • You find some evidence that some objects are out of control (maybe someone did a programming error and they are leaking objects). A code change should fix it
  • Everything is normal, but it just eats a lot of memory. In that case, talk with your operator (if it is not you) to see how to size your server JVM memory. Have a look at this:

How can I increase the JVM memory?

Community
  • 1
  • 1
Jorge_B
  • 9,712
  • 2
  • 17
  • 22