Skip to content

htop used memory does not exact match psutil.used memory #15

Description

@avnikonenko

htop and psutil don’t use the same definition of “used memory.” On Linux, /proc/meminfo exposes several categories (Buffers, Cached, SReclaimable, etc.), and each tool decides which of these counts as “used.”
psutil memory

available memory: the memory that can be given instantly to processes without the system going into swap. This is calculated by summing different memory metrics that vary depending on the platform. It is supposed to be used to monitor actual memory usage in a cross platform fashion.
[Psutil memory](https://psutil.readthedocs.io/en/latest/index.html#psutil.virtual_memory)

htop:

"Used" is calculated as the total - (free+buffers+cache+shared). Shows “How much of RAM currently holds something”
This method of calculation, which subtracts free, buffer, and cache memory from the total, is considered an older approach.
 It differs from the more modern calculation used by tools like free and top, which use the MemAvailable field from /proc/meminfo to determine used memory as Used Memory=MemTotal−MemAvailable.
The MemAvailable value is considered a more accurate representation of memory immediately available for new processes, as it accounts for memory that cannot be freed quickly, such as dirty pages

https://www.reddit.com/r/linuxquestions/comments/1de8sx2/htop_ram_usage_value_why/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions