views:

81

answers:

4

Hi all,

I am trying to figure out why Jetty 6.1.22 is running out of memory on my laptop. I have 2 web applications running JBoss Seam, Hibernate (with EHCache), and separate Quartz scheduler instances.

With little load, the server dies throwing OutOfMemory.

What can I look for? Would you think that I am not properly closing handles for input streams or files?

I tried profiling my application with Netbeans, but it works off and on. Usually, it ends up locking up even though it doesn't use that much CPU or memory.

Walter

A: 

What are you JVM's execution parameters?

Try increasing available heap memory though -Xms (default) -Xmx (max) and -Xmn (min) JVM's flags.

You can also monitor your Application Server execution with JConsole. It's usually helpful for finding out where is you application leaking.

Pablo Santa Cruz
Thanks - I forgot about JConsole. I used that in the past to see what was going on and it is a very helpful tool. Hopefully, it is more stable than Netbeans.
+2  A: 

add -XX:+HeapDumpOnOutOfMemoryError when invoking the jvm and when you get the OOM situation you will get a .hprof file dumped. You can open it later with several tools and you'll be able to see where the memory is going...

The tool I use is Eclipse Memory Analyzer, it's pretty good.

raticulin
Thanks - I will give that a try.
A: 

I can strongly recommend attaching to the troublesome program with jvisualvm in the JDK.

This allows you to investigate memory and cpu usage over time and inspect what happens in general.

Thorbjørn Ravn Andersen
I don't seem to have jvisualvm, I'm starting with JConsole first.
jvisualvm came in Sun Java 6 update 10 or so. Which JVM do you use?
Thorbjørn Ravn Andersen
1.6.0_15 on Ubuntu Linux
jvisualvm should be in the jdk. Perhaps it is not present in OpenJDK? You have "sudo apt-get install sun-java6-jdk"? (might require an additional repository on newest ubuntus)
Thorbjørn Ravn Andersen
Hmm, so I noticed that with just the application started (before anyone actually hits the site), it's using almost all of the PermGen space. My PermGen size is 88MB and with it started, it's using about 76 MB (for 2 web applications).
I will play around a little bit with JVM settings. I am using Linode 360 as my target platform so I have 360MB of ram to allocate minus whatever I need for other stuff.
Another question regarding my web application and tuning it better - If my web applications are identical except they have a different view (XHTML, CSS, and some configuration), wouldn't it be smarter to bundle it as an EAR so that the PermSize can be smaller (if I'm using the same services, then I don't need to load classes twice).
well, increasing the PermSize seemed to resolve the issue. I also decreased the maximum heap size to what I think I have with Linode360. I think my max PermSize needs to be around 100MB.
A: 

Some months ago I wrote a post in my blog about diagnosing out-of-memory errors. It could be useful: http://eyalsch.wordpress.com/2009/06/17/oome/

Eyal Schneider
Thanks - I will give this a try after JConsole (step 1 of your list / guide).