禁用MacOSX的虚拟内存

在Windows中我一直都是禁用虚拟内存的。感觉这样可以快一些。还可以减少不必要的硬盘读写。对于MacOSX也有同样的想法。在网上搜索了一下,有一些使用SSD的兄弟为了保护SSD,延长寿命,也想关闭mac的dynamic_pager。找到以下两个方法可以帮助我们关闭MAC的虚拟内存:

方法一:

  1. Open Terminal in the Applications -> Utilities folder. Type the following, hitting Return after each command.

    cd /etc — this brings you to the file you want to work with
    sudo cp /etc/rc /etc/rc.orig — this makes a copy of the file etc/rc called etc/rc.orig; enter administrative password when asked.
    sudo pico /etc/rc — this brings you into a text editing program to edit the file; enter administrative password when asked.

  2. Use the arrow keys to go down until you see one of these lines:
    • In osx 10.3.x: dynamic_pager -F ${swapdir}/swapfile
    • In osx 10.2.x: dynamic_pager -H 40000000 -L 160000000 -S 80000000 -F ${swapdir}/swapfile
  3. Type # at the beggining of the dynamic pager line. Hit Control-X to save file then answer Y and hit Return.
  4. Type exit — this logs you out of the Terminal session.
  5. Now delete the old swap files securely. In osx 10.3.x, type sudo srm /private/var/vm/swapfile*. In osx 10.2.x, you should use a security application such as PGP to securely delete any remaining swap files located in /private/var/vm/. The swap files are named: swapfile*
  6. Restart your computer and check to make sure swap is off. Start terminal and type ls -al /private/var/vm/ — this lists the contents of /private/var/vm/. You should see no files named: swapfile*

方法二:

  1. sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
  2. sudo rm /private/var/vm/swapfile*


By Lu Jun

80后男,就职于软件行业。习于F*** GFW。人生48%时间陪同电子设备和互联网,美剧迷,高清视频狂热者,游戏菜鸟,长期谷粉,临时果粉,略知摄影。

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.