700mb of memory used, but processes memory usage appears not match it?

Discussion in 'Command Line' started by postcd, Aug 31, 2014.

  1. postcd

    postcd Member

    Messages:
    80
    Likes Received:
    6
    Trophy Points:
    8
    Hello, these processes is all what "top" returns long time:

    [​IMG]

    but i dont see how the processes memory usage match the 756Mb memory usage mentioned in the top sumary..? why? how i can discover where the memory is used, this is strange, because i cant believe vps is using that much memory, only these processes.

    thx

  2. SHarper

    SHarper New Member

    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    check out the linuxatemyram website. I can't post links yet, but you can find it. You are seeing the discrepency because Linux caches stuff in memory, but it doesn't prevent processes from using said memory. It's a performance enhancement.
  3. ryanvade

    ryanvade Administrator Staff Member Staff Writer

    Messages:
    1,391
    Likes Received:
    454
    Trophy Points:
    83
    Getting right memory usage is trickier than one may think. The best way I could find is:

    Code:
    echo 0 $(cat /proc/`pidof process`/smaps | grep TYPE | awk '{print $2}' | sed 's#^#+#') | bc
    Where "process" is the name of the process you want to inspect and "TYPE" is one of:

    • Rss: resident memory usage, all memory the process uses, including all memory this process shares with other processes. It does not include swap;
    • Shared: memory that this process shares with other processes;
    • Private: private memory used by this process, you can look for memory leaks here;
    • Swap: swap memory used by the process;
    • Pss: Proportional Set Size, a good overall memory indicator. It is the Rss adjusted for sharing: if a process has 1MiB private and 20MiB shared between other 10 processes, Pss is 1 + 20/10 = 3MiB
    Other valid values are Size (i.e. virtual size, which is almost meaningless) and Referenced (the amount of memory currently marked as referenced or accessed).

    You can use watch or some other bash-script-fu to keep an eye on those values for processes that you want to monitor.

    For more informations about smaps: http://www.kernel.org/doc/Documentation/filesystems/proc.txt.

    reference: http://stackoverflow.com/questions/3853655/in-linux-how-to-tell-how-much-memory-processes-are-using
  4. Mitt Green

    Mitt Green Member

    Messages:
    69
    Likes Received:
    39
    Trophy Points:
    18
    Code:
    free -m
    Gives you actual information about memory used. Look at 'buffers/cache'
    ryanvade likes this.

Share This Page