Ernest
Ernest

Reputation: 962

how to monitor memory in a spring + tomcat application?

i have a spring application that i want to optimize , its using much memory, it was fine when few people used it, but numbers scaled a little and i have no idea where to start . Is there a way of knowing which class and methods take what kind of resources ?

Upvotes: 3

Views: 2498

Answers (2)

ruhsuzbaykus
ruhsuzbaykus

Reputation: 13380

I think JMX will be a good start. Using Spring's JMX support, it will be very easy to configure your beans to integrate with JMX.

http://static.springsource.org/spring/docs/3.0.5.RELEASE/reference/jmx.html

Upvotes: 2

Benjamin Muschko
Benjamin Muschko

Reputation: 33436

The best way to start with this is using a profiler. There are a lot of products out there. I personally like YourKit. It's a matter of preference. Using a profiler you can easily find out the number of instantiated classes from where in the code. You might simply have a memory leak.

In general I think it's a good idea to set up your application server/servlet container to expose their internals over JMX. You'll just have to enable the JMX agent by setting JVM startup parameters. You can then connect to your server and monitor CPU and memory consumption using JConsole or VisualVM. VisualVM provides a simple profiling plugin.

Upvotes: 2

Related Questions