My Java EE 6 application running on JBoss 6 has recently started having memory problems.
Situation
- Production server.
- Small-medium sized application using JPA2/Hibernate with default caching settings. ~170 classes.
- DB size ~1.8gb, 90% of it belonging to binary data simply fetched by servlets without any special caching.
- Session timeout was recently increased from 2 hrs to 10.
- JVM config: -Xrs -Xms1024M -Xmx1024M -XX:MaxPermSize=512M -Dsun.rmi.dgc.client.gcInterval=3600000 -server
- JBoss running as service.
- Almost all controller classes in ViewScope
Two questions with these facts in mind:
-
How would I troubleshoot these OOMEs? JConsole doesn’t find JVMs running as services. Ideally I’d have to be able to inspect relevent objects such as sessions to find the memory thief.
-
Could this OOME be legit, with the increased session timeout in mind, and the solution simply be to increase the heap size? The application has been in use since September 2011 without any earlier memory problems. Session timeout was drastically increased about two months ago.
It seems logical that a session will use a certain amount of memory in JBoss. Increasing the session time out will probably result in more sessions in memory at any one time – so you’ve probably increased the memory requirement of your application.
The simplest (initial) resolution would be to increase the heap allocation to your application. For example, set
-Xmx2g(this doubles the JVM memory to 2 GiB – your current setting is 1 GiB). Obviously, your system should have sufficient physical memory available.If this simply delays your OOMEs, you’ll want to analyse your heap. Enable:
-XX:-HeapDumpOnOutOfMemoryErrorThis will create a physical dump of the heap, for analysis. You may find you have a memory leak, or just that each application session has a certain memory footprint – then either limit the sessions or increase the memory allocation to suit.