Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Memory usage not clear
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Memory usage not clear

collaborandocollaborando Member
edited September 2011 in Help

below the result of "top" :

Mem:    262144k total,    45456k used,   216688k free,        0k buffers
Swap:        0k total,        0k used,        0k free,        0k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                
    1 root      15   0  2824 1376 1220 S  0.0  0.5   0:00.50 init                   
 1142 root      14  -4  2304  624  436 S  0.0  0.2   0:00.00 udevd                  
 1365 root      25   0 35548 1240  944 S  0.0  0.5   0:00.00 rsyslogd               
 1383 root      18   0  8240 1092  684 S  0.0  0.4   0:00.00 sshd                   
 1390 root      25   0  3116  888  716 S  0.0  0.3   0:00.00 xinetd                 
 1397 root      18   0  6744  780  472 S  0.0  0.3   0:00.00 saslauthd              
 1398 root      18   0  6744  488  180 S  0.0  0.2   0:00.00 saslauthd              
 1405 root      18   0  6984 1164  624 S  0.0  0.4   0:00.00 crond                  
 1419 root      15   0 11112 3256 2664 S  0.0  1.2   0:00.06 sshd                   
 1422 root      15   0  6224 1648 1404 S  0.0  0.6   0:00.01 bash                   
 1447 root      15   0  2520 1040  868 R  0.0  0.4   0:00.00 top                    

45M of RAM used but sum of %MEM of all process is 4%.

4% of 256M Memory total is not 45M.
Where my memory is used?

OS: CentOS 6
VPS: 128M / 256M

thanks a lot.

Comments

  • Hi

    Use free -m

    # free -m
                 total       used       free     shared    buffers     cached
    Mem:          4031        192       3839          0          3         49
    -/+ buffers/cache:        138       3893
    Swap:         1023          0       1023
    

    In my example I am using 138 MB.

    If you want to know the memory used but every process, then is another story. Mmm, in a KVM/Xen/physical platform, generally I take the RES column, but I am not sure.
    In openVZ this isn't valid, the processes use more RAM than RES shows.

  • kristalkristal Banned
    edited September 2011

    use command "ps v" to see which app takes what exaclty

    to save some memory: apt-get --purge remove syslog-ng rsyslog udev cron

    also change ssh to dropbear

  • yomero said: If you want to know the memory used by every process

    ps_mem

  • I think most of that occurs with the lowendscript:

    http://www.lowendbox.com/blog/wordpress-cheap-vps-lowendscript/

  • collaborandocollaborando Member
    edited September 2011

    This is my free -m ( @yomero )

                      total       used       free     shared    buffers     cached
             Mem:     256         38        217          0          0          0
             -/+ buffers/cache:   38        217
             Swap:     0          0          0
    

    Results of ps_mem (see @circus comment)

      Private  +   Shared  =  RAM used       Program
    
     228.0 KiB +  69.5 KiB = 297.5 KiB       udevd
     316.0 KiB + 118.0 KiB = 434.0 KiB       xinetd
     96.0 KiB + 454.0 KiB = 550.0 KiB       saslauthd (2)
     596.0 KiB + 116.5 KiB = 712.5 KiB       crond
     620.0 KiB + 180.0 KiB = 800.0 KiB       init
     684.0 KiB + 128.5 KiB = 812.5 KiB       rsyslogd
       1.0 MiB + 156.0 KiB =   1.1 MiB       bash
      ---------------------------------
                                4.7 MiB
    

    Top command is above in my first post.

    4.7M are used by programm where are the rest of used memory?

    @drmike: at this time I don't want optimize my memory usage I want know where my memory is used. :)

    Thanks.

  • @drmike, no I meant lowendscript is purging the bits that @kristal suggests up there.

  • kristalkristal Banned
    edited September 2011

    is this a 64bit system?
    is this xen or open?

  • @collaborando

    Well, because that you are in an OpenVZ VPS, the ps_mem isn't accurate, as I said, openVZ manages the memory in a different way. How? I am not sure, but look at the VIRT columns in top (htop is better :D ), in some processes is a better way to measure the RAM consumption in OpenVZ.

  • Don't use rsyslog, it wastes too much ram on a OpenVZ VPS.

  • dmmcintyre3 said: Don't use rsyslog, it wastes too much ram on a OpenVZ VPS.

    Really? I don't use it too, but I don't see any significant gain. How much is "too much ram"? Less than 1-2MB IMO

  • kristalkristal Banned
    edited September 2011

    on an open vz, usually 96 or 128, everything is too much :P must be strict with ram control :->

    just to use resouces in the most efficient way that is :P

    install debian 5 :->

  • dmmcintyre3dmmcintyre3 Member
    edited September 2011
    [root@lion ~]# free -m
                 total       used       free     shared    buffers     cached
    Mem:           256         55        200          0          0          0
    -/+ buffers/cache:         55        200
    Swap:            0          0          0
    [root@lion ~]# service rsyslog stop
    Shutting down system logger:                               [  OK  ]
    [root@lion ~]# free -m
                 total       used       free     shared    buffers     cached
    Mem:           256         24        231          0          0          0
    -/+ buffers/cache:         24        231
    Swap:            0          0          0

    31mb for a syslog daemon is too much.

    The best way I have found for knowing how much ram something uses on a openvz vps is to run free -m, stop it, then run free -m again due to openvz's allocation (not usage) based memory limits

    On my KVM VPS, ps_mem reports more ram used than free -m:

     ps_mem.py
     Private  +   Shared  =  RAM used       Program 
    
     80.0 KiB +  22.5 KiB = 102.5 KiB       klogd
    128.0 KiB +  34.5 KiB = 162.5 KiB       syslogd
    140.0 KiB +  32.0 KiB = 172.0 KiB       acpid
    112.0 KiB +  72.0 KiB = 184.0 KiB       mingetty (2)
    132.0 KiB +  63.5 KiB = 195.5 KiB       init
    284.0 KiB +  31.5 KiB = 315.5 KiB       udevd
    296.0 KiB + 158.0 KiB = 454.0 KiB       dropbear (2)
    196.0 KiB + 284.5 KiB = 480.5 KiB       mysqld_safe
    592.0 KiB +  52.0 KiB = 644.0 KiB       crond
    396.0 KiB + 288.5 KiB = 684.5 KiB       bash
    736.0 KiB +  86.5 KiB = 822.5 KiB       exim
    648.0 KiB + 271.5 KiB = 919.5 KiB       nsd (3)
      2.7 MiB +  98.0 KiB =   2.8 MiB       python26
     14.9 MiB +   1.7 MiB =  16.6 MiB       nginx (2)
      8.4 MiB +   8.9 MiB =  17.3 MiB       php-fpm (3)
     18.3 MiB + 252.0 KiB =  18.5 MiB       mysqld
    ---------------------------------
                             60.3 MiB
    =================================
    
     Private  +   Shared  =  RAM used       Program 
    
    [root@tiger ~]# free -m
                 total       used       free     shared    buffers     cached
    Mem:           122        116          5          0          9         57
    -/+ buffers/cache:         50         72
    Swap:          258          0        258
  • WTF, my rsyslog doesn't use so much. Or it has memory leaks? Because at the start it uses like 2-3MB ram

  • On a OpenVZ VPS?

  • collaborandocollaborando Member
    edited September 2011

    @dmmcintyre3 thank you for suggest
    afeter service rsyslog stop

                    total       used       free     shared    buffers     cached
      Mem:           256         13        242          0          0          0   
      -/+ buffers/cache:         13        242 
      Swap:            0          0          0
    

    rsyslog takes 25M on my OpenVZ VPs with CentOS6.

    I found this about optimizing difference between VIRT and RES memory on OpenVZ:
    http://www.lowendbox.com/blog/reduce-stack-limit-for-multi-thread-apps/

    @yomero thank you.

  • Yeah, that post is useful too :D

  • Are there any noticeable downsides in reducing stack limit?

  • Some software can crash, but, that happens with extreme settings like... ulimit -s 32 or sth ike that

Sign In or Register to comment.