| Just a quick experiment: I started 4 copies of VLC. `top` shows this: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1806287 adam 20 0 1091068 74664 56228 S 0.0 0.2 0:00.22 vlc
1806426 adam 20 0 1091064 74548 56128 S 0.0 0.2 0:00.21 vlc
1806537 adam 20 0 1091064 74572 56144 S 0.0 0.2 0:00.22 vlc
1806600 adam 20 0 1091064 74960 56536 S 0.0 0.2 0:00.23 vlc
Summing RES (RSS) gives 298744.VLC loads many shared libraries: $ lsof -p 1806426 | grep .so | wc -l
195
I'd hope some/most of those are shared between the instances of VLC and are included in SHR (if I'm reading the top man page correctly).Doing RES-SHR isn't totally correct either. Those shared pages might be "marked as shared" (i.e, a .so that's only loaded by one process). But lets assume that most of what VLC uses as SHR is shared libraries, and they're used by each instance. RES-SHR = 73708 I also ran `free` before and after launching the 4 instances of VLC.
Used increased by 66068. Hard to rely on the accuracy of this number since this is a desktop system and I'd imagine used goes up and down all the time. But it's strikingly close to the RES-SHR figure. IMHO just summing RES isn't correct. Linux memory usage is complex. |