views:

124

answers:

2

Hello,

I have numerous Spring Framework-based applications that run on a Tomcat 5.5 server. Some of them have their own instances, some share a server with other applications. The one thing they all have in common is that they require huge amounts of memory, more than I think they should really require. Are there any tools out there for profiling Tomcat servers ?

To further elaborate, these run on Ubuntu 9.04, fully patched, with access to 3 GB of memory (about half of which it actually takes up).

+1  A: 

Take a look at JConsole. Tomcat by itself exposes a lot of info via JMX as well.

That said, 1.5GB for an application may not be that grotesque. Depending on the application, of course - if it's a "Hello World", then you've got problems :-)

ChssPly76
The main application in question is spread across 6 applicationContext-*.xml files with a combined total of about 110 beans, 85% of them being singletons. Those that aren't are special templated model object prototypes that are dynamically selected through the UI. The largest objects that *should* (haven't confirmed this with a profiler) be taking up space are the Hibernate SessionFactory and the Hibernate Validators, the rest are fairly thin objects.
Alex Marshall
One of my main concerns is that the application takes 3 minutes to start on production, and when we're doing maintenance on the system, we literally lose money for every minute that the system's down. Tomcat takes a long time to start and allocate all that memory. Is there any way the application can just grab one big chunk right on startup ?
Alex Marshall
I strongly doubt that 3 minute startup time is caused by memory allocation; it's much more likely caused by DB pool + SessionFactory (especially on large schema with lots of mappings) + whatever other resource and / or computation intensive items you may be initializing during startup. Spring and Tomcat add some overhead too but it should be rather small compared to the rest. That said, you really need to profile this instead of guessing. Once you know what takes most time / most memory it should be easier to figure out the cause.
ChssPly76
+1  A: 

There's a fair few Java profiling tools:

You just need to attach the profiler to the JVM on startup.

You could also take a look at Lamba probe, but it's more for monitoring:

http://www.lambdaprobe.org/d/index.htm

Also take a look at:

http://stackoverflow.com/questions/948549/open-source-java-profilers

Jon
Thank you very much for your response, it's much appreciated.
Alex Marshall