Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process.memory_full_info().swap double counts the swapped size on Linux (Ubuntu 16.04) #1222

Closed
loop-evgeny opened this issue Feb 20, 2018 · 2 comments

Comments

@loop-evgeny
Copy link

When I get memory_full_info().swap for a .NET Core process on Linux the value reported is double that shown in /proc/PID/status under "VmSwap".

From looking at memory_full_info in _pslinux.py, it seems that the regex "Swap.*:\s+(\d+)" is counting both the "Swap:" and "SwapPss:" lines, which double-counts the same memory usage.

$ uname -a
Linux linuxtest21 4.4.0-1050-aws #59-Ubuntu SMP Tue Jan 30 19:57:10 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

cat /proc/2722/smaps |grep Swap
Swap:                328 kB
SwapPss:             328 kB
Swap:                  8 kB
SwapPss:               8 kB
Swap:                288 kB
SwapPss:             288 kB
Swap:                  8 kB
SwapPss:               8 kB
Swap:                  4 kB
SwapPss:               4 kB
Swap:                  4 kB
SwapPss:               4 kB
Swap:                  4 kB
SwapPss:               4 kB
Swap:                 36 kB
SwapPss:              36 kB
...

Swap and SwapPss each add up to the same value as VmSwap in /proc/PID/status and memory_full_info().swap returns their sum. I'd expect it to return only the sum of the "Swap:" lines, i.e. the same as VmSwap.

@loop-evgeny loop-evgeny changed the title Process.memory_full_info().swap returns double counts the swapped size on Linux (Ubuntu 16.04) Process.memory_full_info().swap double counts the swapped size on Linux (Ubuntu 16.04) Feb 21, 2018
giampaolo added a commit that referenced this issue Mar 13, 2018
… (swap proportional set size) and plain 'swap'. Not anymore.
@giampaolo
Copy link
Owner

This should now be fixed.

@giampaolo
Copy link
Owner

We were also erroneously summing "Pss:" and "SwapPss" together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants