MAC OSX 關閉 Swap

2014052117:06

OSX 10.9.2

Swap檔案存放在

$ ls -l /private/var/vm/swapfile*
-rw-------  1 root  wheel    67108864  3  3 11:52 /private/var/vm/swapfile0
-rw-------  1 root  wheel  1073741824  5 21 17:05 /private/var/vm/swapfile1
-rw-------  1 root  wheel  1073741824  5 21 17:05 /private/var/vm/swapfile2
-rw-------  1 root  wheel  1073741824  5 21 17:05 /private/var/vm/swapfile3


查詢目前 swap 的使用情形

$ sysctl vm.swapusage
vm.swapusage: total = 3072.00M  used = 1797.25M  free = 1274.75M  (encrypted)



關閉 Swap

$ sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
(順便要刪掉 /private/var/vm/swapfile* )



重新啟用 Swap

$ sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist


參考:
Mac Virtual Memory – What it is, the Swap Location, and How to Disable Swap in Mac OS X