{"id":18359519,"url":"https://github.com/zfdang/free-for-macos","last_synced_at":"2026-03-10T12:36:17.122Z","repository":{"id":214700956,"uuid":"737150471","full_name":"zfdang/free-for-macOS","owner":"zfdang","description":"A memory usage tool for macOS (similar with 'free' in Linux)","archived":false,"fork":false,"pushed_at":"2024-07-14T08:01:28.000Z","size":36,"stargazers_count":48,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T13:37:09.591Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zfdang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-30T01:37:46.000Z","updated_at":"2025-04-05T12:04:02.000Z","dependencies_parsed_at":"2024-01-02T08:02:51.186Z","dependency_job_id":"a0dba06c-fe7a-4054-882c-ec46bbc8222e","html_url":"https://github.com/zfdang/free-for-macOS","commit_stats":null,"previous_names":["zfdang/free-for-macos"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/zfdang/free-for-macOS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfdang%2Ffree-for-macOS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfdang%2Ffree-for-macOS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfdang%2Ffree-for-macOS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfdang%2Ffree-for-macOS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zfdang","download_url":"https://codeload.github.com/zfdang/free-for-macOS/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfdang%2Ffree-for-macOS/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30333589,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T05:25:20.737Z","status":"ssl_error","status_checked_at":"2026-03-10T05:25:17.430Z","response_time":106,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T22:23:07.954Z","updated_at":"2026-03-10T12:36:17.097Z","avatar_url":"https://github.com/zfdang.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# free for macOS\n\nA memory usage utility for macOS  (similar with 'free' in Linux)\n\nThis utility is designed to act like 'free' on Linux systems.  It is a tool to display memory usage statistics. Since the Mach microkernel design is different with Linux, the values reported are not exactly the same with what you can get from a Linux system. These metrics are almost aligned with outputs from 'Activity Monitor\".\n\n```\n❯ free -h\n               total           used           free         cached            app          wired\nMem:        32.00 GB       18.69 GB      337.48 MB       12.98 GB       15.48 GB        2.04 GB\nSwap:         0.00 B         0.00 B         0.00 B\n```\n\n# Installation\n\n### HOMEBREW:\n\n   A Homebrew formulae is available at https://github.com/zfdang/homebrew-free-for-macOS\n   \n   To install via Homebrew, run the following:\n\n      brew tap zfdang/free-for-macOS\n      brew install free-for-macOS\n\n   If we can collect enough stars, this formulae will be submmited to offical Homebrew repository.\n\n### COMPILATION:\n\n   You need a compiler, some headers, and a Mach-based system.  On Darwin, you can type make:\n\n      make\n\n   And out will pop a 'free' executable.  On other systems, it may require modification of the Makefile and/or source.\n\n   Either run \n\n      make install\n\n   or put the free executable in a public place and the man page in a sensible place.\n\n# USAGE:\n\n```\n❯ free -v\nfree: version 1.1.0\n❯ free\n               total           used           free         cached            app          wired\nMem:     34359738368    20060241920      282902528    14016593920    16661561344     2149351424\nSwap:              0              0              0\n❯ free -h\n               total           used           free         cached            app          wired\nMem:        32.00 GB       18.69 GB      337.48 MB       12.98 GB       15.48 GB        2.04 GB\nSwap:         0.00 B         0.00 B         0.00 B\n❯ free -h -s 1\n               total           used           free         cached            app          wired\nMem:        32.00 GB       18.67 GB      344.30 MB       12.99 GB       15.48 GB        2.03 GB\nSwap:         0.00 B         0.00 B         0.00 B\n\n               total           used           free         cached            app          wired\nMem:        32.00 GB       18.66 GB      336.53 MB       13.02 GB       15.42 GB        2.07 GB\nSwap:         0.00 B         0.00 B         0.00 B\n\n               total           used           free         cached            app          wired\nMem:        32.00 GB       18.68 GB      337.17 MB       12.99 GB       15.48 GB        2.04 GB\nSwap:         0.00 B         0.00 B         0.00 B\n\n               total           used           free         cached            app          wired\nMem:        32.00 GB       18.65 GB      343.44 MB       13.02 GB       15.42 GB        2.06 GB\nSwap:         0.00 B         0.00 B         0.00 B\n^C\n```\n\nor \n\n\tman free\n\n# Explanation:\n\nTotal memory is fetched from host_info().\n\n`https://developer.apple.com/documentation/kernel/1502514-host_info`\n\nSwap information is fetched from sysctl().\n\n`https://forums.macrumors.com/threads/sysctl-and-ctl_vm.145571/`\n\nAll other memory information is fetched from host_statistics64().\n\n`https://developer.apple.com/documentation/kernel/1502863-host_statistics64`\n\nHere are the methods to calculate memory statistics:\n\n## free memory\n\n```\n// free = free_count - speculative_count; verified\nformatBytes((vm_stat.free_count - vm_stat.speculative_count) * page_size, mem.free, sizeof(mem.free), human);\n\n```\n\n## used memory\n```\n// truely-free = free-count - speculative_count\n// used = total - truely-free - cached; partially verified, still has small discrepancy with \"activity monitor\"\nformatBytes(hbi.max_mem - (vm_stat.free_count - vm_stat.speculative_count + vm_stat.purgeable_count + vm_stat.external_page_count) * page_size, mem.used, sizeof(mem.used), human);\n```\n\n## cached memory\n\n```\n// cached files memory  = purgeable_count + external_page_count; verified\nformatBytes((vm_stat.purgeable_count + vm_stat.external_page_count) * page_size, mem.cached, sizeof(mem.cached), human);\n```\n\n## app memory\n\n```\n// app memory = internal_page_count - purgeable_count; verified\nformatBytes((vm_stat.internal_page_count - vm_stat.purgeable_count) * page_size, mem.app, sizeof(mem.app), human);\n```\n\n## wired memory\n\n```\nMemory that is used by the kernel to run essential system processes. \nIt is essentially occupied by the kernel and cannot be freed.\n```\n\n\n# Reference\n\n## mdoc online editor\n\n```\nhttps://roperzh.github.io/grapse/\n```\n\n## how to calculate memory in macOS:\n\n```\nhttps://novov.me/blog/posts/mixedmemories\n```\n\n```\nhttps://stackoverflow.com/questions/14789672/why-does-host-statistics64-return-inconsistent-results\n```\n\n\n## related codes\n\n```\nhttps://github.com/dcantrell/darwin-free\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzfdang%2Ffree-for-macos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzfdang%2Ffree-for-macos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzfdang%2Ffree-for-macos/lists"}