When I attempt to run the purge command, I get the same error every time.
[ERROR] <CPDevice.c:3816> Unable to create new counter client.
[ERROR] <CPOSX.c:1172> Unable to get user client so as to poke the kernel.
Unable to purge disk buffers, error #-2.
I've tried with and without sudo, initially thinking that perhaps it's unable to due to not having proper access, and they simply didn't program in a permissions check. It's the same error though.
I have a dual Xcode installation, which I believe may be the issue here. I have 3.2.6 installed to a custom directory (/Xcode 3) and I have Xcode 4.6.3 from the Mac App Store. I've installed the most recent (2013.4) Command Line Tools from within Xcode 4. I'm running OS X 10.7.4 Lion.
Before anyone tells me that I should let the OS manage inactive memory on it's own because it does it fine, no, it doesn't. Not in the slightest. Normally it works well enough not to bother me. But whenever I use any type of VM, I encounter issues with the memory never releasing.
For example, I can start an instance of an emulation VM. It'll use about 600 MB of memory. When I terminate the emulation entirely, the memory does not release. On top of that, if I go back and rerun the exact same emulation, the 600 MB sitting in inactive doesn't get reused like one might hope. No, it just sits there. And another 600 from the free pool gets used. And when that second emulation is terminated, I now have 1.2 GB of inactive memory. Now normally this would be fine, if the inactive memory released when all the free memory was used. But it doesn't. It just sits there and never releases. It'll swap to disk instead.
This issue is particularly annoying with virtualization VMs that use 4 GB or even more of RAM within my normal usage. Restart those more than once and new things slow to a crawl due to disk swapping.
I used to use the purge command all the time on 10.5 Leopard with Xcode 3.1.4, and issues on Leopard weren't nearly this bad with automatic memory management. I just used purge to get more of a clean slate without having to reboot. I can't even do that now. And unlike some people would tell you, it is a serious problem.
Any ideas would be appreciated. One more thing. I have used xcode-select
to select Xcode 4.6.3 as opposed to 3.2.6. I only use 3.2.6 for development and compiling. Macports, Homebrew, and some other things, demand Xcode 4 to be installed and selected though, which is the only reason I have it. But if I remember correctly, purge also didn't work when I had Xcode 3 selected instead.
sudo purge
orsudo bash
thenpurge
.