Skip to content

Instantly share code, notes, and snippets.

@pythoninthegrass
Forked from anildigital/cleanup_swap.md
Last active June 26, 2023 17:06
Show Gist options
  • Save pythoninthegrass/52a4642fc31a7e110fe1145608b0e3df to your computer and use it in GitHub Desktop.
Save pythoninthegrass/52a4642fc31a7e110fe1145608b0e3df to your computer and use it in GitHub Desktop.
Cleanup swap space on macOS
#!/usr/bin/env bash
# To see current swap usage
sysctl -a | grep swap
# Monitor swap usage
vm_stat 60
# 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
sudo fs_usage | grep swapfile
# Or for page ins/outs
sudo fs_usage | grep PAGE_
# To see what WindowServer process is doing exactly
sudo spindump -reveal $(pgrep WindowServer)
# or for kernel_task
sudo spindump -reveal 0
@pythoninthegrass
Copy link
Author

pythoninthegrass commented Jun 26, 2023

Comment out lines to be skipped. Could refactor into mini functions w/,main, but why tho ¯\_(ツ)_/¯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment