Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VmSize = physical memory + swap?

I have a little question regarding VmSize, in the documentation it's supposed to be the application's usage of memory.

However on my system:

VmSize = physical memory + swap VmHWM seems more like what the application actually would be using.

[root@sun ~]# free -m
             total       used       free     shared    buffers     cached
Mem:         12012       9223       2788          0        613       1175
-/+ buffers/cache:       7434       4577
Swap:         3967          0       3967


[root@sun ~]# cat /proc/8268/status
Name:   mysqld
State:  S (sleeping)
Tgid:   8268
Pid:    8268
PPid:   1
TracerPid:      0
Uid:    89      89      89      89
Gid:    89      89      89      89
FDSize: 512
Groups: 89 
VmPeak: 15878128 kB
VmSize: 15878128 kB
VmLck:         0 kB
VmPin:         0 kB
VmHWM:   7036312 kB
VmRSS:   7036312 kB
VmData: 15839272 kB
VmStk:       136 kB
VmExe:     10744 kB
VmLib:      6356 kB
VmPTE:     16208 kB
VmSwap:        0 kB
Threads:        265
SigQ:   0/96048
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000087007
SigIgn: 0000000000001000
SigCgt: 00000001800066e9
CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: 0000001fffffffff
Seccomp:        0
Cpus_allowed:   fff
Cpus_allowed_list:      0-11
Mems_allowed:   00000000,00000001
Mems_allowed_list:      0
voluntary_ctxt_switches:        2567
nonvoluntary_ctxt_switches:     77

Any idea of why? I try to get the usage of memory for this application in particular but this result doesn't really make sense.

Thanks.

like image 723
rubymonk Avatar asked Jun 18 '13 16:06

rubymonk


1 Answers

VMsize is the "address space" that the process has in use: the number of available adresses. These addresses do not have to have any physical memory attached to them. (Attached physical memory is the RSS figure)

You can verify this by allocating a chunk of memory with p = malloc(4 * 1024 * 1024);, and not doing anything to *p: the VmSize will increase by 1K pages, but the RSS will be (about) the same. (your program will have more adressable memory, but it does not address it, so the memory does not need to be attached )

like image 108
wildplasser Avatar answered Sep 28 '22 01:09

wildplasser