2

We have a RHEL5 system with 25gb RAM, 2x Quad Core Intel Xeon (8 cores altogether) and randomly get heap size errors.

Our java options are -Xmx10240m -Xms10240m -XX:PermSize=256m -server -Xss1024k. Is there anything wrong with the above config?

errors:

java.lang.OutOfMemoryError: Java heap space
    at net.sf.ehcache.store.DiskStore.throwableSafeExpireElementsIfRequired$
    at net.sf.ehcache.store.DiskStore.spoolAndExpiryThreadMain(DiskStore.ja$
    at net.sf.ehcache.store.DiskStore.access$800(DiskStore.java:65)
    at net.sf.ehcache.store.DiskStore$SpoolAndExpiryThread.run(DiskStore.ja$

TIA

Mike Yockey
  • 4,539
  • 20
  • 41
Mang G11
  • 211
  • 5
  • 12
  • Are you using 64 bit system and java or RHEL + PAE kernel? It's a good chance you have to debug the memory dump to figure out what leaks. – Sergey Benner Jan 23 '12 at 00:50
  • 64 bit RHEL sorry forgot to mention. – Mang G11 Jan 23 '12 at 01:59
  • Heap OOM usually means a leak. What part of heap is the problem? eden,survivor,tenured? Have you used jconsole or this tool http://www.yourkit.com/java/profiler/ it has 30 days eval but we used to it find our leak. If you have a big heap dump consider having a big memory debug machine as well otherwise it will take awhile to swap it. – Sergey Benner Jan 23 '12 at 10:32

3 Answers3

1

Run your JVM with -XX:+HeapDumpOnOutOfMemoryError and open the dump with the profiler to analyze what's eating your heap. Otherwise you will spend endless hours guessing what could have gone wrong.

Also see this SO post.

Community
  • 1
  • 1
mindas
  • 25,644
  • 13
  • 93
  • 149
  • More than likely, it's going to be ehcache. :-) (Granted, the stack that throws the OOME isn't really related to who's using the most memory. My statement is only because it shows evidence of ehcache is in use within the JVM.) – ziesemer Jan 23 '12 at 00:29
  • Yes, but you can go deeper and see the contents of Ehcache. I, for example, have seen 1.5G strings being cached a few times - which can get you to the source of the problem. – mindas Jan 23 '12 at 00:32
1

If you are running through that much memory perhaps you have another issue with your application itself.

Try setting the following options on your JVM and running again:

-XX:HeapDumpPath=myHeapDumpPath
-XX:+HeapDumpOnOutOfMemoryError

Then run the heap dump through a memory analyzer. The Eclipse Memory Analyzer works well and is open source. It has an option to analyze for memory leaks.

Given the classes are from ehcache most likely you are caching too many objects and running out of memory. You probably need to tweak your ehcache settings to limit how much it stores. The memory analyzer tool should help determine what you are caching too much of.

Michael
  • 2,280
  • 2
  • 23
  • 47
0

It would be clearer to write -Xmx10g. Time to profile. You can start with VisualVM which is free and use it to get some profile information about where the memory is all disappearing to.

bmargulies
  • 91,317
  • 38
  • 166
  • 290