Best unofficial Apache Server developers community |
|
I'm completely new to Linux and I'm just trying to understand where all my RAM is going. I've got a pretty fresh install of Xubuntu running as a VMWare guest, and I've given it 1.5GB RAM to play with. After only running two apps starting up Tomcat servers and also running Firefox, I've got hardly anything left. 160MB according to free -m. Looking at the output from Top, I see Java appearing twice, each stealing about 1/2 Gig resident memory. Both Tomcat instances use the same jdk, I would have thought I'd only see Java there once. What's the story? I had a screenshot but unfortunately couldn't post it being under 10 rep. Update The free -m output requested:
Top:
posted via SuperUser
|
|
 
|
This is not a Linux issue, it's a Java issue. The same will happen on Windows, though I guess it may be more eager in swapping out part of those Tomcat processes. First of all, two instances of Tomcat are going to start two instances of the JVM in two separate processes. The question is whether you actually need two instances of Tomcat. You can easily run two different webapps in the same instance. Second, Java as a language based on garbace collection likes to have a lot of memory to play in and tends to use a large percentage of the maximum heap it's allowed to use, because that way it does lesss work overall in garbage collection. It also doesn't tend to give unused memory back to the OS because it might need it again soon. If you are certain your webapps need a lot less than half a gig memory, you can start Tomcat with a smaller maximum heap by setting the environment variable CATALINA_OPTS to "-Xmx256m". If your app sometimes needs more memory but you want it to shrink down its heap more quickly, set it to "-XX:MaxHeapFreeRatio=20 -XX:MinHeapFreeRatio=10" - but this may reduce performance. |