How to disable swap usage on Mac OS and why you should do it (in 2020)

I just got myself a Macbook Pro with 32GB of RAM.

So imagine my surprise when after a few days of running it, I looked at my memory in activity monitor and noticed that I was running with almost 14GGB of swap ?!?!? (It eventually ballooned to 32-35 GB of disk at one point)

This had been a recurring theme on my old machine with 16GB of Memory. The swap would increase up to 16GB sometimes, as much at 19-20GB+ and I couldn’t understand why. I just assumed that when I got more memory the problem would go away.

So after asking around on twitter, I started doing some research on possibly turning off my swap file. This may seem drastic, but many years ago when I was still a Windows user, I’d managed to do the same thing without much ill effect, so I figured … why not?

The instructions and a detailed explanation of what you’re doing are here. But the long and short of it is that you need to boot into recovery mode and then run the command

sudo nvram boot-args="vm_compressor=2"

When you boot back into MacOS, you can check that you are running in this mode by running this command

$ sysctl -a vm.compressor_mode

to which you should see this in response
vm.compressor_mode: 2

At first I was very nervous about running out of memory, but then I noticed something interesting. MacOS was still using swap!!!!

I was bummed, I thought I’d gotten it wrong somehow ?, but I hate rebooting my machine so I left things alone and continued to monitor memory/swap usage.That’s when I realized something interesting … My swap file usage wasn’t disabled, it was just now extremely conservative. I’ve been using this for almost a month now and the most swap I’ve ever seen it use is 300MB.

This is my current system swap usage

MacOS running with swap "disabled"

MacOS running with swap “disabled”

Amazing right?!

Its exactly what I wanted, and I’ve run so far without any memory errors or problems. And that’s while I am also using Memory Clean 3, to help me occasionally reclaim memory. I’ve used Memory clean for years and just recently upgraded.

I must mention that I’m not doing anything particularly stressful like video editing, gaming. Just running a couple of docker containers and running some Rspec tests from time time time, so your mileage may vary. If you do turn on conservative swap file usage on MacOS please report back or tweet at me to let me know how it goes!

Update: 10/23/20
I found that enabling “Automatic Graphics switching” in the Energy Saver section of System preference made the system use up more RAM.

This makes sense, the dedicated AMD Radeon Pro 5500 GPU on my Macbook Pro has 4GB of its own dedicated GDDR6 memory (VRAM), so it makes sense that the integrated graphics system uses RAM when it needs to. 

Apple appears to have fixed the usage of RAM by the integrated graphics to to 1.5GB
Unfortunately this seemed to put lots of memory pressure on my system after a few days, to where I’d see the occasional crash.

So for now I have disabled this option, and my system seems more stable now as my Macbook Pro uses the GPU memory exclusively and doesn’t touch my RAM 🙂

 

How to run a Webkit Nightly build on windows.

This is very straight forward, but for those who think it might be complicated. Here is all it entails.

inside a webkit nightly build folder Continue reading

Safari/Webkit Nightly scores a 90 on Acid 3 test …

I am  a huge fan of Safari and Webkit … what it lacks in cool features, it more than makes up for in blazing fast speed and javascript performance.

When the Microsoft released a beta for IE8, I was prompted to run the Acid3 test on the browsers I had on my system.

Here are the results I got on my windows box, testing all the installed browsers against Acid 3 Continue reading

Broken Safari for windows.

Safari for Windows (3.0.4) became my current favorite browser by (to my trained eye) slaughtering Opera in Javascript performance.
Hopefully that changes with Opera 9.25. Of late though, I’ve been having trouble with it. Safari initially broke on my Windows Laptop a few weeks ago, popping up a debugger prompt and closing immediately if I cancelled out of it.It kept running on my main workstation, however … that is until this evening, now its doing the same on my desktop.
I realize how poorly supported this browser is, because there is no place to file a bug report except from in the browser itself. Shouldn’t there be an active bug database or something for Safari on windows?

If anyone knows how to fix this please let me know … I want my super fast javascript back!
[Click on Images to see bigger versions]

Broken Safari

Visual Studio debugging Safari Crash

How to solve problem with USB devices not responding on resumption from standby in Bootcamp.

So … I’m running Windows XP on a 17″ Macbook Pro with Bootcamp …
Every now and then, when I put the laptop on Standby and try to resume work from where I left off, the USB devices stop responding all together.
This is a big problem for me, since

  • I put my laptop in and out of standby several times a day
  • work off an external 250GB Hard drive.
  • am pretty hopeless without a wireless mouse

I poked around online, but didn’t really find anything on Google or at the Apple bootcamp forum.
So I decided to try fixing it on my own. Continue reading