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

heim fails to report total memory usage on WSL1 #305

Open
ClementTsang opened this issue Jan 10, 2021 · 2 comments
Open

heim fails to report total memory usage on WSL1 #305

ClementTsang opened this issue Jan 10, 2021 · 2 comments
Labels
A-memory Area: heim-memory crate C-bug Category: something isn't working O-linux Operating system: Linux P-medium Medium priority

Comments

@ClementTsang
Copy link

ClementTsang commented Jan 10, 2021

I've been having issues with using the memory library within a WSL1 instance on Ubuntu 18.04.

I tried to run the "free" example on a WSL1 instance using Ubuntu 18.04, and it fails with this error:

Error: Error { source: Kind(InvalidData), context: Some(File { path: "/proc/meminfo" }) }

It works fine on the WSL2, though.

Taking a look at the /proc/meminfo files of both of these, I think the issue is that the "MemAvailable" field doesn't exist on WSL1:

MemTotal:       33483712 kB
MemFree:        22743224 kB
Buffers:           34032 kB
Cached:           188576 kB
...

On the WSL2, it looks like:

MemTotal:       26220580 kB
MemFree:        26108576 kB
MemAvailable:   25898488 kB
Buffers:            4716 kB
Cached:             8320 kB
...

Guessing that since one field is missing, it's tripping up the number of lines check in memory.rs?

@ClementTsang ClementTsang changed the title heim fails to report total memory usage on Ubuntu 18.04 on WSL2 heim fails to report total memory usage on WSL1 Jan 10, 2021
@ClementTsang
Copy link
Author

Tested a bit more, seems like I initially messed up the comparison and the issue just seems to be on WSL1.

@svartalf
Copy link
Member

Awesome investigation, thanks for doing it!

Based on this one function from psutil, we can't expect to have MemAvailable: line for kernels < 3.14 and should calculate it manually.

@svartalf svartalf added A-memory Area: heim-memory crate C-bug Category: something isn't working O-linux Operating system: Linux P-medium Medium priority labels Jan 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-memory Area: heim-memory crate C-bug Category: something isn't working O-linux Operating system: Linux P-medium Medium priority
Projects
None yet
Development

No branches or pull requests

2 participants