Skip to content

Linux memory usage parsing seems to use the wrong unit #341

@ClementTsang

Description

@ClementTsang

Was looking through the meminfo parsing code and noticed that at here, the strings in /proc/meminfo are parsed as kilobytes:

Information::new::<information::kilobyte>(value)

However, as far as I understand it, it seems like this the wrong unit - this Red Hat doc states:

While the file shows kilobytes (kB; 1 kB equals 1000 B), it is actually kibibytes (KiB; 1 KiB equals 1024 B). This imprecision in /proc/meminfo is known, but is not corrected due to legacy concerns - programs rely on /proc/meminfo to specify size with the "kB" string.

So if I'm understanding this correctly, it's probably better to switch it to

Information::new::<information::kibibyte>(value)

as otherwise users may get values that are slightly inaccurate if they aren't aware.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions