Skip to content

Repository files navigation

MacMemMonitor

macOS 13+ Apple Silicon Swift 5 MIT build

English | 中文

A tiny, always-on-top desktop panel that shows macOS memory pressure — and, optionally, CPU load — at a glance. It mirrors the Memory / CPU panels of Activity Monitor so you can keep an eye on the machine without opening Activity Monitor. Single-file Swift, zero third-party dependencies, built with swiftc. The UI is bilingual — switch 简体中文 / English from the menu bar (default 简体中文).

Screenshots

Standard mode — memory + CPU panels
Standard mode — memory + CPU panels

Minimal mode — compact bars
Minimal mode — compact bars

How it works

Everything comes from public, unprivileged system interfaces — no special permissions:

  • Memoryhost_statistics64(HOST_VM_INFO64) for VM page counts (wired / compressor / free / internal / external / purgeable), sysctl hw.memsize for the total, sysctl vm.swapusage for swap. The columns:
    • 物理内存 / 已使用内存 / 已缓存文件 / 已使用的交换 (physical / used / cached files / swap used)
    • App 内存 / 联动内存 / 被压缩 (app / wired / compressed)
    • 已使用内存 is physical − free − cached (with a fall-back), so used + cached + free ≈ physical.
  • Memory graph — the left graph plots either memory usage (App + Wired + Compressed ÷ physical) or, with the footer 对齐系统 / Match System checkbox, an Activity-Monitor-style pressure approximation (Wired + Compressed share — low when healthy). Either way it is colored per time-segment by the real kernel pressure level (sysctl kern.memorystatus_vm_pressure_level → green / yellow / red), so a historical yellow stretch stays yellow after pressure returns to normal.
  • CPU panel (optional)host_statistics(HOST_CPU_LOAD_INFO) ticks → system / user / idle percentages and a stacked load graph; proc_listpids for the process count and getloadavg for the 1-minute load average.
  • This app's own CPU — shown in the footer, measured with getrusage(RUSAGE_SELF) over wall-clock, so you can see the monitor's own footprint.
  • Minimal mode — collapses to one progress bar for memory (and, if the CPU panel is enabled, one for CPU usage).

Settings (language, refresh interval, CPU panel, minimal mode, graph mode, always-on-top) persist in UserDefaults.

Tested on

  • Apple Silicon (arm64), macOS 13 or later.

Build

Requires the Xcode Command Line Tools (xcode-select --install) — no Xcode project, no Swift Package Manager, no third-party dependencies.

./build.sh          # produces ./MacMemMonitor.app

The core compile command is the same in build.sh and CI:

swiftc -O -swift-version 5 -target arm64-apple-macos13.0 -o MacMemMonitor.app/Contents/MacOS/MacMemMonitor main.swift

build.sh also generates the icon (./makeicon.sh), writes Info.plist, and ad-hoc signs the bundle.

Run

open ./MacMemMonitor.app

Controls live in the bottom strip: refresh interval (0.5 / 1 / 2 / 5 s), 对齐系统 / Match System (graph height = system pressure instead of usage), CPU panel toggle, 最小 / Compact mode, 置顶 / On Top (always-on-top). Language is switched from the menu bar. No permission prompts.

First launch may be blocked by Gatekeeper (the app is ad-hoc signed, not notarized) — right-click the app and choose Open, or clear the quarantine flag: xattr -dr com.apple.quarantine MacMemMonitor.app.

Sharing the built app

Limit Detail
Architecture Apple Silicon (arm64) binary; rebuild on Intel if needed
Signing ad-hoc (codesign -s -); recipients right-click → Open, or xattr -dr com.apple.quarantine
Notarization none — not distributed via App Store
macOS 13 or later

Caveats

  • The "Match System" pressure height is an approximation. The real kernel algorithm is private; when Match System is on, the plotted height is the Wired + Compressed share (low when healthy, rising as the compressor works) — an approximation of Activity Monitor's pressure, not an exact value. The default graph instead plots real memory usage. The per-segment color is always the real kernel pressure level.
  • No total thread count. An accurate system-wide thread count needs elevated privileges, so it is deliberately not shown; the CPU panel shows the process count and the load average instead.
  • The CPU panel is system-wide (host_statistics), not this app. This app's own usage is computed separately with getrusage and shown in the footer.
  • The user percentage folds in nice time. Self-CPU% can exceed 100% on multi-core work (it is only lower-bounded at 0).
  • The process count is sampled between two proc_listpids calls, so it is approximate.
  • The UI is bilingual (简体中文 / English, switchable from the menu bar, default 简体中文); the README is bilingual too.

License

MIT © 2026 ExWang

About

A compact macOS memory & CPU monitor — an Activity Monitor-style desktop panel. Single-file Swift, zero dependencies.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages