开发者

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开发者_StackOverflow中文版 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 ?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜