Linux high memory usage (top total mismatch)

memory usageprocesstop

I havea poor mans vps – 256MB dedicated RAM. I have installed LAMP. No website is currently UP on the server yet.

The memory usage is still 225MB (only 31 MB free).

I have measured using top and another method. Top says around 225mb used, but if I sum up the processes, it comes to be only 20%.

Another script I am using to measure the memory:

#!/bin/bash
bean=`cat /proc/user_beancounters`
guar=`echo "$bean" | grep vmguar | awk '{ print $4;}'`
priv=`echo "$bean" | grep privvm | awk '{ print $2;}'`
let totl=guar/256
let used=priv/256
let free=$totl-$used
echo "VPS Memory:"
echo "  total: $totl mb   used: $used mb   free: $free mb"

gives same result (225MB used).

I have rebooted the server, but still 225MB memory is being used. How can I find the culprit process. please help!

============

Output of ps efax -o command,vsize,rss,%mem,size indicates that only 20% (aournd 50MB) is actually used by processes.

(apt-get install imagemagick is failing because of low RAM. I guess I need to go for higher memory like 512 MB. I thought the failure might be due to this "spurious" memory usage).

Is there any way to know if the memory is indeed available as cache (top shows buffer/cach as 0 – I heard that if the RAM was available as cache, it would appear as "bufffers or cache).

Output of free -m:

free -m
             total       used       free     shared    buffers     cached
Mem:           256        226         29          0          0          0
-/+ buffers/cache:        226         29
Swap:            0          0          0

Its showing free buffers/cache also as on 29 MB 🙁

Best Answer

Linux will use as much ram as it can as cache which will be given up if other processes require more memory. Have a look here for some more information.