1

I have a Web application running on my 64-bit Windows Server 2003, Oracle 11G database and Apache Tomcat 6.0 Web Server.

Application is on live environment and around 3000 of user using the application I have encountered Java Heap Out Of Memory Error. After increasing Heap space it's resolved.

Now again I am facing same issue, below is the error stack trace:

Exeption in thread "http-8080-10" java.lang.OutOfMemoryError: Java heap space Aug 23, 2013 8:48:00 PM com.SessionClunter getActiveSessions Exeption in thread "http-8080-11" java.lang.OutOfMemoryError: Java heap space Exeption in thread "http-8080-4" Exeption in thread "http-8080-7" java.lang.OutOfMemoryError: Java heap space

2 Answers 2

1

Your problem could be caused by a few things (at a conceptual level):

  • You could simply have too many simultaneous users or user sessions.

  • You could be attempting to process too many user requests simultaneously.

  • You could be attempting to process requests that are too large (in some sense).

  • You could have a memory leak ... which could be related to some of the above issue, or could be unrelated.

There is no simple solution. (You've tried the only easy solution ... increasing the heap size ... and it hasn't worked.)

The first step in solving this is to change your JVM options to get it to take a heap dump when a OOME occurs. Then you use a memory dump analyser to examine the dump, and figure out what objects are using too much memory. That should give you some evidence that will allow you to narrow down the possible causes ...

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot stephen will check and back
0

If you keep getting OutOfMemoryError no matter how much you increase the max heap, then your application probably has a memory leak, which you must solve by getting into the code and optimizing it. Short of that, you have no other choice but keep increasing the max heap until you can.

You can look for memory leaks and optimize using completely free tools like this:

  1. Create a heap dump of your application when it uses a lot of memory, but before it would crash, using jmap that is part of the Java installation used by your JVM container (= tomcat in your case):

    # if your process id is 1234
    jmap -dump:format=b,file=/var/tmp/dump.hprof 1234
    
  2. Open the heap dump using the Eclipse Memory Analyzer (MAT)

  3. MAT gives suggestions about potential memory leaks. Try to follow those.

  4. Look at the histogram tab. It shows all the objects that were in memory at the time of the dump, grouped by their class. You can order by memory use and number of objects. When you have a memory leak, usually there are shockingly too many instances of some objects that clearly don't make sense all. I often tracked down memory leaks based on that info alone.

Another useful free JVM monitoring tool is VisualVM. A non-free but very powerful tool is JProfiler.

4 Comments

Thanks janos i am just looking how to use MAT if you have any Link kindly share
Just the online documentation: help.eclipse.org/kepler/index.jsp?topic=/… But you might not need to go too deep. Look at the histogram and sort the objects by memory or by count. Usually the culprit is quite obvious from there. If not so obvious, then maybe it's not a memory leak after all...
Great janos i have taken heap dump but what is the path where i will find the dump file
If you used the jmap command I gave above, the path is what you specified by file=. If you used something else, that depends on what you used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.