Created
July 26, 2016 07:46
-
-
Save pyrtsa/8af2c7cdd34c5371b144cb86a21c8dba to your computer and use it in GitHub Desktop.
Script to keep SourceKitService from eating up all OS resources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
limit="${1-10000000}"; | |
echo "Keeping SourceKitService below $limit KiB of virtual memory." | |
echo "Hit ^C to quit." | |
while true; do | |
sleep 1; | |
p=`pgrep ^SourceKitService$` | |
if [ -n "$p" ]; then | |
vsz=`ps -o vsz -p "$p" | tail -1` | |
if [ $vsz -gt $limit ]; then | |
kill -9 "$p"; | |
echo "`date +%H:%M:%S` Killed SourceKitService $p at $vsz KiB of virtual memory." | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment