Skip to content

Instantly share code, notes, and snippets.

@sfpprxy
Forked from anildigital/cleanup_swap.md
Created June 12, 2023 05:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfpprxy/236c8d7111f15d80d588e725d2563b66 to your computer and use it in GitHub Desktop.
Save sfpprxy/236c8d7111f15d80d588e725d2563b66 to your computer and use it in GitHub Desktop.
Cleanup swap space on macOS

To see current swap usage

sysctl -a | grep swap

Use only when when your system is in a very bad shape

$ sudo pkill -HUP -u _windowserver 

To monitor, what's creating/updating these swap files, run:

$ sudo fs_usage | grep swapfile

Or for page ins/outs, run:

$ sudo fs_usage | grep PAGE_

To see what WindowServer process is doing exactly, run:

$ sudo spindump -reveal $(pgrep WindowServer)

or for kernel_task, run:

$ sudo spindump -reveal 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment