1

I have several applications running in a Tomcat7 instance.

Once in a while, I notice that there are OutOfMemoryErrors in the log.

How can I find out, which application (ideally - which) class causes them?

Update 1 (25.12.2014 11:44 MSK):

I changed something in the application (added a shutdown call to a Quartz scheduler, when the servlet context is destroyed), which may have caused memory leaks.

Now my memory consumption charts look like shown below.

Memory consumption charts

Does any of them indicate memory leaks in the application?

If yes, which one?

Glory to Russia
  • 17,289
  • 56
  • 182
  • 325
  • 1
    Keep in mind that it is usually never as simple as a single class causing it; if you dig into this you do it with the least amount of tunnel vision as you can possibly manage. The OutOfMemory might also happen for valid reasons - that your heap simply isn't big enough for the amount that all joined applications need at a specific peak moment in time. – Gimby Dec 11 '14 at 10:33

3 Answers3

3

There is a good documentation about that http://www.oracle.com/technetwork/java/javase/clopts-139448.html

  • create a heapdump with the vm parameters described in the link above.
  • analyze this heapdump, for example use memoryanalzyer(https://eclipse.org/mat/).
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
soilworker
  • 1,317
  • 1
  • 15
  • 32
1

OOM can occur because of many reasons.

1.) Memory Leaks

2.) Generation of a large number of local variables etc.

OOM is a common indication of a memory leak. Essentially, the error is thrown when there’s insufficient space to allocate a new object.

Few Exception Messages

  1. java.lang.OutOfMemoryError: Java heap space
  2. java.lang.OutOfMemoryError: PermGen space
  3. java.lang.OutOfMemoryError: Requested array size exceeds VM limit
  4. java.lang.OutOfMemoryError: request bytes for . Out of swap space?
  5. java.lang.OutOfMemoryError: (Native method)

More detailed information here and official

refer this and this

Need to analyze the Heap dump/thread dumps etc.

Detecting Memory leak

Community
  • 1
  • 1
Ankur Singhal
  • 26,012
  • 16
  • 82
  • 116
0

You can use jmap . It will give snap shot of java process.

How many objects in memory with size of objects .

jmap -histo #processID
Siva Kumar
  • 1,983
  • 3
  • 14
  • 26