Macchina-CLI / libmacchina

A library providing access to all sorts of system information.
https://crates.io/crates/libmacchina
MIT License
68 stars 20 forks source link

[BUG] Wrong amount of total memory displayed #129

Closed Artur2 closed 1 year ago

Artur2 commented 1 year ago

Describe the bug Wrong calculation of memory total amount To Reproduce Steps to reproduce the behavior:

  1. install
  2. run

Expected behavior

Show 16 GB instead of 16.8 GB

Screenshots

Screenshot 2023-01-20 at 15 00 37

macchina --doctor output

Let's check your system for errors... Here's a summary:

We've collected 18 readouts, including 1 failed read(s) and 1 read(s) which resulted in a warning. Readout "LocalIP" failed with message: Unable to get local IPv4 address.

1 of the 2 unsuccessful read(s) resulted in a warning: Readout "Distribution" threw a warning with message: Since you're on macOS, there is no distribution to be read from the system.

System Information

grtcdr commented 1 year ago

libmacchina isn't actually inaccurate, what you're seeing is the total physical memory as reported by sysctl, not the available physical memory that the application on the right is showing.

Artur2 commented 1 year ago

So, systcl showing wrong total amount of physical memory ? Or what ? I don't understand :)

grtcdr commented 1 year ago

So, systcl showing wrong total amount of physical memory ?

sysctl is showing the correct information, that's exactly the amount of physical memory you have, it's just that certain system components can reserve some of that memory resulting in total and available being different.

macOS, unlike libmacchina, is choosing to report what's available (after memory reductions are taken into account).

There isn't a "right" or "wrong" answer, they're just different statistics.

Artur2 commented 1 year ago

Got it, thank you @grtcdr

grtcdr commented 1 year ago

You're welcome :)