OS X Mavericks Preview: Compressed Memory gives your Mac room to run

Another example of how Apple is trying to make Mavericks more efficient is "Compressed Memory." This technique helps free up memory from dormant apps that don't need it. The net result: your Mac runs and wakes from sleep faster.

If you open a lot of applications, or if some of your apps need a lot of memory, your Mac will slow down. Way down. That's because your Mac runs out of physical RAM to allocate. OS X isn't in the habit of saying no, though, so what it does is create a swap file that gets written to your Mac's hard disk. That swap file contains the contents of inactive memory. Reading from that swap file and writing to it takes time, and that slows the Mac down.

Apple has ameliorated some of the effects of swap memory in machines like the MacBook Air, which uses flash storage instead of a conventional hard drive. The MacBook Air has pretty limited amounts of RAM compared to other Macs but can still run a number of applications simultaneously quicker than Macs with conventional hard drives, thanks to the speed of flash storage. And newer MacBook Airs can go even faster, with speedy PCIe-based storage.

Not all Macs have flash storage, however. And even solid state drives have their limits. The speed of SATA and PCIe interfaces are less than the direct path between the CPU and the installed RAM, creating a bottleneck.

Improving memory efficiency

Apple set out to do things a bit differently in OS X Mavericks, and they've come up with a memory compression scheme that does the trick. Here's how it works:

At any given time, dozens of different processes - applications, background tasks and more - may be running on your Mac. A lot of them you may have absolutely no awareness of, unless you open the Activity Monitor app in your Utilities folder - they're not items that appear in your Dock, and there's no way to interact with them directly.

Before Mavericks memory compression

These processes and the apps you're running may be sitting in memory but not actively using memory. But they're there, and they're grabbing a little piece of your Mac's available RAM. Cumulatively, they take up space and create the potential for slowdowns.

Apple has engineered Mavericks to be aware when your Mac is reaching its physical RAM limit. And when it does, Mavericks leaps into action and figures out which processes are active and which are inactive. It then compresses the memory that the inactive applications have allocated, which frees up more RAM. That keeps your Mac from having to write content out to and read from swap files.

After Mavericks memory compression

According to Apple, compressing and decompressing memory happens "almost instantly," so there's no slowdown and therefore no downside for the user. Apple says that with memory compression on Mavericks, they're seeing 1.4x speed increases in system reponsiveness under load, when opening documents or reactivating inactive applications, even on machines equipped with fast SSDs.

Your Mac has to write out swap files when it goes to sleep and it needs to read the when it wakes up. There's also a big improvement in the time it takes a Mac to wake from standby - 1.5x faster, compared to Mountain Lion.

It's yet another way that Mavericks promises to improve efficiency compared to Mountain Lion and what's come before, which means a faster and better user experience for you.

Have you seen your Mac slow way down as it manages big swap files? Do you think Mavericks will make a big difference for you? How much RAM does your Mac have? I want to hear from you, so please let me know in the comments.