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

Getting memory usage fails from missing information on WSL #82

Open
CosmicHorrorDev opened this issue Aug 7, 2020 · 1 comment
Open

Comments

@CosmicHorrorDev
Copy link
Contributor

CosmicHorrorDev commented Aug 7, 2020

Please provide any of the following information if relevant:

  • rust-psutil version: 3.1.0 (issue is still present in master)
  • target platform info
    • kernel version: uname -a says 4.4, but behavior seems to deviate from mainline kernel
    • architecture: x86_64
    • (if linux) distro: WSL ubuntu 18.04
  • any relevant hardware info:

From cjbassi/ytop#106

In ytop, users trying to run the program with WSL were encountering issues where calling pstuil::memory::virtual_memory() will fail with MissingData due to /proc/meminfo missing MemAvailable. From my brief reading on the topic, this was an attribute that was added in kernel 3.4 (hence my confusion on version 4.4) to give an accurate idea on the amount of available memory left on the system. You can read more on the discussion here where it also mentions that you:

can be estimated from MemFree, Active(file), Inactive(file), and SReclaimable, as well as the "low" watermarks from /proc/zoneinfo.

From this it might be reasonable to provide a fallback where the value is estimated if MemAvailable isn't found in /proc/meminfo.

@cjbassi
Copy link
Collaborator

cjbassi commented Sep 12, 2020

The reason the field is missing is because WSL uses a custom kernel build with that field disabled.

Here's how python psutil handles things: https://github.com/giampaolo/psutil/blob/6242f7411b882d525e5d267de4bcda1079934ea2/psutil/_pslinux.py#L321

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

No branches or pull requests

2 participants