views:

569

answers:

2

Is there any way/tool to profile per-session memory usage in a Java web application?

More specifically I'm using Seam and I have a few objects which are specific for the user or for the user's current session so they're set to be stored in the user's session.

Some time ago my application would run out of memory when hitting a certain number of users so I moved various things out of the session and profiled until I got the memory down. However the memory measurements were at the JVM level. I'd really like a way to monitor memory usage on session level, excluding any non-session memory usage.

Nice to have:

  • Total memory usage for http sessions (which I can compare to whole application memory usage)
  • Per-session memory usage, even averages.
+1  A: 

Have a look at http://messadmin.sourceforge.net/ .

dandamian
A: 

I use Eclipse Mat a lot to diagnose similar issues. If you have big sessions the Session Manager shows up in the "Dominator Tree" report. You can easily distinguish total memory usage by sessions and other parts of the app.

You can drill down to individual sessions and see how much memory is used by each. You can also open each individual session and inspect each object in the session.

It is also a good idea to look at the other reports that MAT provides. Sometimes the results are surprising - for example we had an issue with memory usage that turned out to be a JRE classloader problem.

leonm