LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-18-2016, 10:38 AM   #1
sergey1369
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Rep: Reputation: 0
What is using server memory?


Hello.

I've got a server with 32G RAM. "Free" claims that it is using 29G of 31G.
I've found out that it is using only 18G.

Why 29-18=11G is not marked like a "free"?

Thanks, Sergey.

Code:
My free output:
# free -h
             total       used       free     shared    buffers     cached
Mem:           31G        29G       1.5G         0B        14M        59M
-/+ buffers/cache:        29G       1.6G
Swap:         9.5G        22M       9.5G

### proc memory in gigabytes
# ps axo vsz|awk 'BEGIN {sum=0} /[0-9]/ {sum+=$1;} END {print int(10*sum/1024/1024)/10 "G";}'
3.6G 

# cat /proc/meminfo
MemTotal:       32979652 kB
MemFree:         1607000 kB
Buffers:           17948 kB
Cached:            63516 kB
SwapCached:         1892 kB
Active:            48200 kB
Inactive:          52056 kB
Active(anon):      21580 kB
Inactive(anon):     3084 kB
Active(file):      26620 kB
Inactive(file):    48972 kB
Unevictable:        7404 kB
Mlocked:            7404 kB
SwapTotal:       9999992 kB
SwapFree:        9976876 kB
Dirty:              1360 kB
Writeback:             0 kB
AnonPages:         24924 kB
Mapped:            12460 kB
Shmem:                24 kB
Slab:            7340908 kB
SReclaimable:      28112 kB
SUnreclaim:      7312796 kB
KernelStack:        5640 kB
PageTables:         7052 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    26489816 kB
Committed_AS:     277044 kB
VmallocTotal:   34359738367 kB
VmallocUsed:    24103600 kB
VmallocChunk:   34329677000 kB
HardwareCorrupted:     0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:        8120 kB
DirectMap2M:     3102720 kB
DirectMap1G:    30408704 kB



So used memory expected to be 18G:

proc memory + buffers + cached + shared + slab
3.6G+14M+59M+0M+7340908K+7312796K=
3.6G+0G+0G+7G+7G= ~18G

But free says 29G
MemTotal - MemFree 
32979652 kB - 1607000 kB
31.4G-1.5G=~29G
 
Old 08-18-2016, 11:19 AM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,552

Rep: Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112
How about the output of
Code:
top -n 1 -o %MEM
I don't know how that "proc memory" command is supposed to work, but it doesn't. That same command on my machine prints "78.3G", but this system only has 16 GB of RAM plus 8 GB of swap.

Last edited by suicidaleggroll; 08-18-2016 at 11:22 AM.
 
Old 08-19-2016, 05:06 AM   #3
sergey1369
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Hi, Suicidaleggroll.

Thanks for you reply.

It's OK and expected. This command just adds ps's vsize for all processes and print sum.
Due to shared libraries mappings it's expected that allocated virtual memory
is more then physical.

Here is top 10 processes...

Code:
# ps axO vsize|sort -rnk 2| head
 PID    VSZ S TTY          TIME COMMAND
13150 193072 S ?        00:00:00 console-kit-dae
 2341 163336 S ?        00:49:16 multipathd
 3125 152360 S ?        05:28:11 hpasmlited
 3574 143060 S ?        05:11:45 cmanicd
19496 132860 S ?        00:02:29 memcached
22891 120508 S ?        00:06:26 rsyslogd
 2965  97872 S ?        00:01:32 multipathd
 8670  83888 S ?        00:00:00 sshd
 8534  83888 S ?        00:00:00 sshd
18840  83888 S ?        00:00:00 sshd
Sorry, you command doesn't work good for my server (ALL process have 0.0% MEM).
So I used VIRT sorting instead. Here is the table.

Code:
# top -n 1

top - 11:54:56 up 759 days,  3:48,  2 users,  load average: 0.01, 0.03, 0.00
Tasks: 594 total,   1 running, 593 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.1 us,  0.1 sy,  0.0 ni, 99.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:  32979652 total, 31587796 used,  1391856 free,   121044 buffers
KiB Swap:  9999992 total,    21256 used,  9978736 free,   106780 cached

  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND           
13150 root      20   0  188m 2528 1656 S     0  0.0   0:00.69 console-kit-dae   
 2341 root      rt   0  159m 3668 2840 S     0  0.0  49:16.87 multipathd        
 3125 root      20   0  148m  840  652 S     0  0.0 328:11.77 hpasmlited        
 3574 root      20   0  139m  904  784 S     0  0.0 311:45.67 cmanicd           
19496 nobody    20   0  129m  932  764 S     0  0.0   2:29.48 memcached         
22891 root      20   0  117m 5588  972 S     0  0.0   6:26.90 rsyslogd          
 2965 root      rt   0 97872 3744 2944 S     0  0.0   1:32.67 multipathd        
 8534 root      20   0 83888 1836  988 S     0  0.0   0:00.06 sshd              
 8670 kminkov   20   0 83888 1344  492 S     0  0.0   0:00.01 sshd              
18821 root      20   0 83888 3888 3040 S     0  0.0   0:00.01 sshd              
18840 serg      20   0 83888 1928 1040 S     0  0.0   0:00.08 sshd              
26726 nginx     20   0 80556  740  420 S     0  0.0   3:50.67 nginx             
26727 nginx     20   0 80556  804  420 S     0  0.0   3:48.53 nginx             
26729 nginx     20   0 80556  732  420 S     0  0.0   3:50.77 nginx             
26730 nginx     20   0 80556  752  320 S     0  0.0   0:00.00 nginx             
26731 nginx     20   0 80556  744  420 S     0  0.0   3:50.78 nginx             
26732 nginx     20   0 80556  828  420 S     0  0.0   3:49.51 nginx
 
Old 08-19-2016, 12:22 PM   #4
24x7servermanagement
Member
 
Registered: Jul 2016
Location: India
Distribution: CentOS, Redhat, Ubuntu and Debian
Posts: 57

Rep: Reputation: Disabled
How about

Code:
 ps aux | head -1;ps aux --no-headers| sort -rn -k 3 | head
 
Old 08-19-2016, 02:52 PM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,606
Blog Entries: 4

Rep: Reputation: 2996Reputation: 2996Reputation: 2996Reputation: 2996Reputation: 2996Reputation: 2996Reputation: 2996Reputation: 2996Reputation: 2996Reputation: 2996Reputation: 2996
Superficially, it seems that your machine is using most of the memory right now for file-system buffers and caches ... because it can.

The last thing that Linux wants to do is to have memory available to it that isn't being used for something. If there is no "pressure" for memory, as in your case, then it will squirrel-away things in every cubbyhole that it can find. These cubbyholes will be the first things to be discarded if-and-when memory pressure starts to develop.

For instance, if you ever read a file, or ever used a command, then data related to these things will hang-around in memory just in case you do use them again (which is actually "quite likely"). This is why we say that operating systems are designed to be very lazy.

Last edited by sundialsvcs; 08-19-2016 at 02:53 PM.
 
Old 08-19-2016, 02:57 PM   #6
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,552

Rep: Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112
Quote:
Originally Posted by sundialsvcs View Post
Superficially, it seems that your machine is using most of the memory right now for file-system buffers and caches ... because it can.
But it's not. Look at the output of free again, disk cache is only using 59 MB.

I'm not sure where it's going, odd.
 
Old 08-19-2016, 03:42 PM   #7
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,711

Rep: Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279
Quote:
Originally Posted by suicidaleggroll View Post
But it's not. Look at the output of free again, disk cache is only using 59 MB.

I'm not sure where it's going, odd.
That is leaving out the page cache, dentry cache, kernel page tables,... The disk cache is rather short lived.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
VPS Memory Usage High. Why? Debian 5, mail server and web server. iamdanhenry Linux - Server 5 03-08-2012 08:38 PM
All of the server memory 4 GB ram used; redhat 2.6.9; samba server 3.0! Help. admir330 Linux - Server 4 12-21-2008 07:56 AM
Out Of Memory problems. My server is down. Memory logs attached. guarriman Linux - General 7 06-10-2008 08:46 AM
Difference between resident memory,shared memory and virtual memory in system monitor mathimca05 Linux - Newbie 1 11-11-2007 05:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration