|
|
|
|
|
by adamzegelin
1442 days ago
|
|
Isn't summing RSS going to end up with the wrong numbers? My understanding is that RSS is memory allocated (heap + stack) + executable pages inclusive of shared libraries. i.e, if 10 processes load libfoobar which is 10MB of code, each processes RSS value will be 10MB higher. So if you sum RSS you see 10 x 10MB or 100MB extra usage. But the pages for that library will be shared across processes, with the result that "real ram usage" only goes up by 10MB. Please correct me if I'm wrong. This is based on my understanding of Linux too. FreeBSD might be different. |
|
I started 4 copies of VLC. `top` shows this:
Summing RES (RSS) gives 298744.VLC loads many shared libraries:
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.