Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

Understanding RAM usage on Linux

0

50 views

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:

             total     used     free    shared    buffers    cached
Mem:          1419     1380       39         0          8       111
-/+ buffers/cache:     1259      160       
Swap:          509       68      441

Top:

    VIRT   RES   SHR   %MEM   COMMAND
   74764   36m  6032    2.6   Xorg
    750m  500m  3436   35.5   java
    881m  408m   10m   28.8   java
    6128  1876  1588    0.1   vmtoolsd
   26156  3408  2672    0.2   vmware-user-load
    409m  104m   15m    7.4   firefox-bin
    2632  1060   776    0.1   top
    3032  1264   812    0.1   init
    All zeroes after here.

asked June 24, 2011 3:12 am CDT
posted via SuperUser

1 Answer

0
 

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.

answered June 24, 2011 3:28 am CDT

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions
Understanding SSL
May 24, 2011