4

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 :(

4 Answers4

5

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.

user9517
  • 114,104
  • 20
  • 206
  • 289
  • That site says it better than I ever could have. Thanks for posting it. – Cakemox Oct 14 '10 at 09:22
  • 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). –  Oct 14 '10 at 14:01
  • As I added in the question, "free -m" shows that even buffer/cache free memory is 29 MB. According to http://www.linuxatemyram.com/, if RAM was really available, it would show as free in the buffer/cache line. Am I missing something? –  Oct 14 '10 at 14:06
1

try using from following link how is use by which process and update back

http://studyhat.blogspot.com/2010/09/memory-use-by-which-process-centos-rhel.html

Rajat
  • 3,329
  • 21
  • 29
0

Try these commands

top -n 1

or

ps efax -o command,vsize,rss,%mem,size

The answers to this question on superuser.com also can be of help "How can I display the memory usage of each process if I do a ps ef"

hookenz
  • 14,132
  • 22
  • 86
  • 142
  • Its giving a list of about 20 processes (cant add as comment due to msg limit). However, the sum of the memory usage is around 20% (same with output of top). I am now thinking that it is indeed that linux is using the ram as "cache". –  Oct 14 '10 at 13:56
0

Guys, thanks to all for responding. Turned out mysql was using 139MB of "virtual memory". As my VPS does not have SWAP enabled, virtual memory was being taken from the RAM.

(And TOP doesnt display virtual memory in the % usage column -so missed it completely!).

Did two good things to reduce the memory requirement :

1) skipd-innodb in /etc/mysql/my.cnf 2) systemwise ulimit of 256 in /etc/rc

(it was unlimited earlier on causing huge memory footprint).

cheers, JP