Skip to content

Incorrect macOS RAM Usage Statistics? #1573

@ghost

Description

I remember hearing from you all in the past that htop very intentionally calculates ram usage differently from top and also intentionally gives contradicting values between the two programs. You explained why you chose to do this but I can't remember what the reason was. Right now, how you do it is (active_count + wire_count) * page_size, as can be seen here:

mtr->values[MEMORY_METER_USED] = (double)(vm->active_count + vm->wire_count) * page_K;
I am in the process of correcting macOS ram usage for a lot of software I'm stumbling across on GitHub, because a lot of people are doing it completely wrong and honestly, imo, everyone should be doing what Apple does in their official top(1) utility. I wanted to present my solution which is how top(1) does it and see if you all would approve of the idea of me using this solution in htop like I am attempting to do for many other software.

This is what top(1) does: https://github.com/apple-opensource/top/blob/e7979606cf63270663a62cfe69f82d35cef9ba58/globalstats.c#L433-L435 Note this link is providing source code from an unofficial mirror of Apple's Open Source projects, because Apple's official source code repositories for top(1) have been taken away from public viewing. It is now closed-source I guess. It gets ram by doing (wire_count + inactive_count + active_count + compressor_page_count) * page_size. See these other pull requests I've made for more details:

If you happen to like this idea and are willing to accept my code contribution I will go ahead and make a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    MacOS 🍏MacOS / Darwin related issuesenhancementExtension or improvement to existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions