Sweepfor Mac

Mac maintenance

What 'sudo purge' Actually Does on Mac (and When to Use It)

A deep dive into the macOS purge command — what it really frees, when it helps, and why on Apple Silicon Macs you almost never need it.

8 min read

You’ve been compiling a project for an hour. Your fans are loud, the system feels heavy, and Activity Monitor says you have 600 MB of free memory. You read somewhere that sudo purge “frees up RAM,” and now you’re wondering whether to run it.

The short answer: yes, it does free memory. The longer answer is that what it frees and how much it helps is more nuanced than the internet suggests, and on Apple Silicon Macs the gain is usually tiny because the OS already manages memory aggressively. Here’s what the command actually does, and when it’s worth running.

What purge does

purge (man page: purge(8)) is part of the developer command-line tools and ships in /usr/sbin/purge. From its man page: it “forces disk and memory caches to be emptied, providing a more ‘cold disk buffer cache’ condition.”

In practice, on macOS, that means:

  1. Flushing disk caches. macOS aggressively keeps file data in memory after you’ve read it, so the next read is fast. Purge tells the kernel to drop those file-backed pages.
  2. Cleaning inactive memory. Memory that the OS classified as “inactive” (used recently but not now) gets reclaimed.
  3. Compressing what it can. The compressed memory pool gets a chance to do its job.

You’ll see the result with vm_stat immediately after — Pages free jumps and Pages inactive drops.

Why this isn’t usually a speedup

Here’s the catch: those caches existed for a reason. macOS keeps recently-used file data in memory because re-reading from SSD, even an Apple-built NVMe, is slower than reading from RAM. By flushing the cache, you’re ensuring the next read of those files will be slow. You traded a measurable RAM number for a measurable I/O slowdown.

Most of the time, this is a bad trade. macOS’s memory manager already drops cached pages the moment something needs the RAM. So if Photoshop is about to allocate 8 GB, the OS will discard 8 GB of inactive cached data automatically. There’s no benefit to pre-emptively doing it.

The exceptions:

  • You’re about to run a memory benchmark and want a clean baseline.
  • A specific app has been using a lot of “wired” or “active” memory that didn’t get released after quit (rare but happens with some pro tools).
  • You want to test what your app’s first-run performance is like (with no caches).

For day-to-day “my Mac feels slow,” sudo purge is almost never the right answer.

Tip: If you're trying to figure out whether you actually need more RAM, look at the "Memory Pressure" graph in Activity Monitor's Memory tab. Green = fine. Yellow = approaching swap. Red = swapping heavily. Anything green for the last hour means more RAM wouldn't help today.

The actual command

sudo purge

That’s it. No flags, no options. It blocks until done. On a Mac with 16 GB of RAM, expect it to take a few seconds. On a 64 GB Mac Studio with a heavy disk cache, it can take 10–30 seconds and the system will feel briefly sluggish.

You need root because flushing kernel caches is a privileged operation.

Before and after

Run this:

vm_stat
sudo purge
vm_stat

The fields that change:

  • Pages free — goes up.
  • Pages inactive — goes down.
  • File-backed pages — drops sharply.
  • Pages purged — increases by the count of pages dropped.

Multiply the page count by 4096 (4 KB pages on macOS) to get bytes. Or grab a friendlier view with top:

top -l 1 | head -10

The PhysMem: line tells you used/wired/free at a glance.

Power users use Sweep tooEven when you know the Terminal commands, Sweep is faster and harder to mess up. Get Sweep free →

What purge does NOT do

A few things people incorrectly assume:

  • It does not “free up swap.” Swap files on disk grow as needed; macOS only shrinks them on reboot or in response to disk pressure. purge doesn’t touch swap.
  • It does not close apps. Your running processes keep their working sets. Only file cache and inactive pages are touched.
  • It does not improve battery life. If anything, the next batch of disk reads after a purge will be slower and slightly more power-hungry.
  • It does not “speed up” your Mac. It briefly makes more memory available, but reduces I/O efficiency for the next several minutes.

When it actually helps (real cases)

After running a bunch of large file operations — say, copying 200 GB of video — your file cache ends up holding metadata for hundreds of thousands of files you’ll never touch again. sudo purge cleans that up. You probably wouldn’t notice the difference, but it’s the textbook case.

Right before launching a memory-heavy app on an older Intel Mac with 8 GB of RAM, where you can see swap is already 2 GB. purge may give you 200–500 MB of breathing room for the next allocation. On Apple Silicon, the memory compressor handles this gracefully without your intervention.

When testing how your app behaves on a “cold” Mac. Useful for QA on launch performance, where you want to know how the app loads when nothing is in cache.

That’s about it.

Apple Silicon specifically

Apple Silicon Macs use unified memory. The CPU, GPU, and Neural Engine share the same RAM, with no copies between pools. Combined with the heavily-tuned memory compressor, the OS aggressively swaps and compresses without performance hits that an Intel Mac would suffer.

The practical upshot: sudo purge on an M-series Mac usually frees a few hundred MB of inactive pages. On a 16 GB M3, that might be 200–600 MB. On a 36 GB M3 Pro, maybe 1–2 GB. None of that’s going to make a noticeable difference in normal use.

The one Apple Silicon scenario where it can help: you’ve been hammering the Neural Engine (image generation, video transcoding with ML upscaling) and the GPU/NE caches haven’t released. Purge clears those. Even then, quitting and relaunching the offending app is more reliable.

Intel Macs

The story is different on Intel Macs, especially with 8 GB of RAM:

  • The compressor exists but is less aggressive.
  • Discrete GPU memory was separate.
  • Apps from a Rosetta era of macOS are gone, but pre-Apple-Silicon Macs often have crufty leftover daemons that hold memory.

sudo purge can recover several hundred MB on an 8 GB Intel MacBook Air during heavy multitasking. It’s a stopgap, not a fix — if you’re hitting this regularly, the long-term answer is “use less stuff at once” or “buy more RAM.”

Skip the Terminal stackSweep does the same cleanup with a UI and a preview before anything is removed. Download Sweep free →

What to do instead

If your goal is “make my Mac faster,” these usually help more than purge:

  1. Find and quit the actual culprit. Activity Monitor → Memory tab → sort by Memory Used, descending. Almost always there’s one outlier.
  2. Check for runaway processes. Sort by % CPU. A daemon stuck in a loop will eat a core and hold memory until you kill it.
  3. Restart the Mac. Old advice for a reason — clears every leak from every app you’ve launched since the last reboot.
  4. Look at swap usage. sysctl vm.swapusage shows total / used / free. If you’re consistently using 5+ GB of swap, you have a working-set problem purge can’t fix.

Memory usage often correlates with disk usage. If your boot drive is 95% full, macOS struggles to manage swap, virtual memory, and caches efficiently. That’s a job for a real cleanup, not purge.

When the command isn’t installed

purge is part of the command-line developer tools. If you’ve never installed Xcode or run xcode-select --install, it might be missing:

which purge

If nothing comes back:

xcode-select --install

That installs the full set of developer command-line tools. After it finishes, purge will be in /usr/sbin/purge.

Doing it on a schedule (don’t)

People sometimes set up cron or a launchd job to run sudo purge every hour “to keep the Mac fast.” This is counterproductive. macOS’s memory manager is well-tuned; periodically wiping its caches just makes the next disk read slower, every hour, forever.

If you really want to demonstrate that to yourself: run a benchmark like dd if=/some/large/file of=/dev/null bs=1m, twice in a row. The second run will be much faster because of the file cache. Now do sudo purge between them. The second run will be back to first-run speed.

A reasonable use of purge

I run sudo purge once in a great while — maybe a few times a year. The pattern is roughly:

  1. I’ve just finished some intensive work (a video export, a big build, a long compile).
  2. I notice memory pressure has been yellow for the last 20 minutes.
  3. I’m about to start something else heavy and I don’t want to deal with the swap-out latency mid-task.

In that case, sudo purge is a quick way to give the next operation a clean slate without rebooting.

For everything else — and “my Mac feels a little slow” specifically — there’s better stuff to try first. Real cleanup, real diagnostics, or just closing the 47 Chrome tabs.

There’s a GUI for thatSweep wraps the Terminal cleanup in a UI you don’t have to memorize. Try Sweep free →

Bottom line

sudo purge is real, and it does free real memory. But it’s a niche tool, not a magic optimizer. If you find yourself reaching for it more than a few times a year, the underlying issue is somewhere else — too many login items, a runaway process, a near-full disk, or genuinely insufficient RAM for your workload.

The actual cleanup wins live in the cache, login item, and orphan-file space — the places where a good cleaner pays for itself in saved disk and saved login time.

← Back to all guides