-
-
Notifications
You must be signed in to change notification settings - Fork 287
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
incorrect virtual memory? #428
Comments
The doc says that |
Thanks. |
Well, the initial question remains: if they intend to display bytes and not kilobytes and you still have terabytes, then there is a problem in sysinfo. If you could maybe confirm? :) |
This is where we're tracking this issue. Your example program seems to be reporting differently than we're reporting in nushell. I'm not sure why yet. I'll try to get back to you on this. I really don't get why it's not working because this is all we're doing. dict.insert_untagged(
"virtual",
UntaggedValue::filesize(process.virtual_memory() * 1000),
); |
@GuillaumeGomez I've gone through this a bit in our code. If you see below, it looks like we're following the model as you used in your example application. You can see where I inserted some pub async fn ps(tag: Tag, long: bool) -> Result<Vec<Value>, ShellError> {
let mut sys = System::new_all();
sys.refresh_all();
let duration = std::time::Duration::from_millis(500);
std::thread::sleep(duration);
sys.refresh_all();
let mut output = vec![];
let result = sys.get_processes();
for (pid, process) in result.iter() {
let mut dict = TaggedDictBuilder::new(&tag);
dict.insert_untagged("pid", UntaggedValue::int(*pid));
dict.insert_untagged("name", UntaggedValue::string(process.name()));
eprintln!("myname {}", process.name());
dict.insert_untagged(
"status",
UntaggedValue::string(format!("{:?}", process.status())),
);
dict.insert_untagged(
"cpu",
UntaggedValue::decimal_from_float(process.cpu_usage() as f64, tag.span),
);
dict.insert_untagged("mem", UntaggedValue::filesize(process.memory() * 1000));
eprintln!("mymem {}", process.memory());
dict.insert_untagged("virtual", UntaggedValue::filesize(process.virtual_memory()));
eprintln!("myvm {}", process.virtual_memory());
... I also tried |
No, your code looks correct as far as I can tell. The issue must be coming from |
Probably. What do you want me to add? When I run your example app, it works correctly. |
Simply some |
@GuillaumeGomez Could this be the problem? Line 258 in 6db49a8
I'm wondering if that code above should be sysinfo/src/windows/process.rs Line 782 in 6db49a8
|
|
I never paid attention but it seems you're right. How weird... When you change to |
This seems to be working much better. let mut sys = System::new_all();
let mut output = vec![];
let result: Vec<usize> = sys.get_processes().keys().cloned().collect::<Vec<usize>>();
for pid in result {
sys.refresh_process(pid);
if let Some(process) = sys.get_process(pid) {
let mut dict = TaggedDictBuilder::new(&tag);
...
dict.insert_untagged("mem", UntaggedValue::filesize(process.memory() * 1000));
dict.insert_untagged(
"virtual",
UntaggedValue::filesize(process.virtual_memory() * 1000),
);
I just wish |
I think the information is returned in KB in linux, so all other systems kinda need to return the same "level". |
Do you mind sending a PR for this fix? Since you found where the problem was coming from... ;) |
I don't think there is anything to PR because the route I took was essentially not to do this: let result = sys.get_processes();
for (pid, process) in result.iter() { because once you do that, you can't call And a worse note - I just saw that now the memory numbers on Linux may be artificially large. Ugh. |
What the hell... There are a lot of things that need to be fixed apparently. |
I was going to try and look at it in WSL2 and see if anything jumps out. |
Thanks, that'd be really appreciated. But I still think that if any path/route leads to invalid data, then there is something to fix. Can you provide a small test code so I can run it locally on my windows and try to fix it please? |
Something is going on in linux as well I think.
This is what
5.8TB vs 1.4GB |
This is the small test code from above, tweaked a bit, that shows how it works in Windows. let mut sys = System::new_all();
let mut output = vec![];
let result: Vec<usize> = sys.get_processes().keys().cloned().collect::<Vec<usize>>();
for pid in result {
sys.refresh_process(pid);
if let Some(process) = sys.get_process(pid) {
println!("name {}", process.name());
println!("mem {}", process.memory() * 1000);
println!("virtual {}", process.virtual_memory() * 1000);
}
} |
I think I may see the problem in Linux. Line 655 in a3099e0
According to
It's reporting in bytes and then |
Great catch! Interested into sending a PR for this one at least? |
I'll reopen since the issue still exists on windows (based on your comments). |
sysinfo/src/windows/process.rs
Line 782 in 639f6af
I'm guessing that this code may not be right because in nushell it's showing that i have terabytes of virtual memory, which i don't have.
nushell
needs the number in bytes so we're doing something like this process.virtual_memory() * 1000 to get bytes.Do you think
nushell
is reporting it the wrong way or is it being calculated the wrong way insysinfo
?The text was updated successfully, but these errors were encountered: