vrvictor
vrvictor

Reputation: 95

java.lang.OutOfMemoryError in tomcat 7

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]]"

Upvotes: 1

Views: 1758

Answers (4)

Jakub Kubrynski
Jakub Kubrynski

Reputation: 14149

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?

Upvotes: 3

Jorge_B
Jorge_B

Reputation: 9872

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?

Upvotes: 0

Bogdan
Bogdan

Reputation: 51

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).

Upvotes: 0

Will Hartung
Will Hartung

Reputation: 118601

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.

Upvotes: 1

Related Questions