Skip to content

Instantly share code, notes, and snippets.

@karnauskas
Forked from anildigital/cleanup_swap.md
Created March 16, 2023 14:57
Show Gist options
  • Save karnauskas/3b47227e6603532ba5beff02b41bf193 to your computer and use it in GitHub Desktop.
Save karnauskas/3b47227e6603532ba5beff02b41bf193 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