views:

191

answers:

2

Hello;

I have a VPS on which I serve Tomcat 6.0. 500mb memory was enough, when I had only two applications. Last week I deployed another web application and formed a new virtual host editing Tomcat server.xml. But the server responses slow down, linux started to eat the swap. When I increased the memory 750 mb it become stable again. But memory is not so cheap so I won't be happy to pay 250 mb RAM for each additional application.

Is "250 mb additional memory need" for each web app normal? Is there any solution to decrease this cost? For example, does "to put common libraries of these applications to shared folder of Tomcat" have positive impact on Tomcat memory and performance?

Note: Deployed applications are web applications that use Spring, hibernate, sitemesh and related libraries, war file size totals up to 30 mb.

Thanks.

+1  A: 

It's unlikely that this memory is being consumed by the Spring / Hibernate / etc. classes themselves. So the size of their .jar files isn't going to matter much. Putting these libraries in Tomcat's shared library directory would help save a bit of memory in that one copy of these classes would be loaded only, but that won't save much.

Isn't it simply more likely that your applications are just using this much memory for data and so forth? You need to use a profiler to figure out what is consuming the heap memory first. Until you know the problem, it's not much use in pursuing particular solutions.

Sean Owen
Yes maybe there is problem in my applications. Indeed my applications are Grails web application, I use basic Grails controllers, services etc. I will search about memory need of a typical Grails application. Maybe there is excessive use of hibernate caching
javanes
A: 

I think you need to measure the memory consumption of the application. You can use JProfiler or Java6 build in profiling tools such as VisualVM and JHat (best way to start).

Check this link for more info: http://java.sun.com/developer/technicalArticles/J2SE/monitoring/

Tal