Increase Your Free RAM

As I described in detail in RAM, free RAM correlates strongly with speed, and running out of free RAM—which in turn increases virtual memory usage—is a major reason for slowdowns. So in this chapter I explore ways to keep more of your RAM free. The things that free up RAM often reduce CPU usage and disk access too, but here I’m looking at cases where RAM is the main consideration.

Of course, the best way to increase your free RAM is to add more (see Add RAM). But if your Mac won’t hold any more or can’t be upgraded, or if you can’t afford to add physical RAM, the steps in this chapter should help.

Reduce the Number of Open Apps, Windows, and Tabs

Look at your Dock right now. How many apps are open? (Open apps have a dot beneath the icon if your Dock is at the bottom of your screen, or next to the icon if your Dock is on the side. If these dots do not appear, go to System Preferences > Dock and check “Show indicators for open applications.”) Of these, how many are you actively using? How many have you even touched in the last hour? I urged you earlier to Quit Inactive Apps, but here I want to provide more detail and ask you to go further—and to develop some new habits.

Each app you run uses at least a bit of RAM, and although its CPU usage may drop to virtually nothing when it’s in the background, it continues to use RAM—sometimes a lot of RAM—until you quit it. Similarly, every new window or tab you open, whether in the Finder or in any other app, requires a chunk of RAM, even if the app is hidden or the window is minimized to your Dock. So the fewer apps, windows, and tabs you have open, the lower your overall RAM usage.

Closing windows and quitting apps is pretty straightforward, but I do have a few specific tips:

  • Quit and (possibly) reopen. When you quit an app, macOS recovers the RAM the app was using. Even if you immediately reopen the app, its RAM usage will likely be less than it was before, because many apps use increasing amounts of RAM as they run but then don’t properly give back what they no longer need (see Watch Out for Memory Leaks, ahead).

  • Don’t just close. As I mentioned earlier, for many Mac apps—especially those that are document-based—merely closing the app’s last open window doesn’t necessarily quit the app. If there’s still a dot by its Dock icon, or if its icon appears when you press ⌘‑Tab to switch between apps, the app is still running, even without any visible windows. Right-click (or Control-click) on the Dock icon and choose Quit from the contextual menu.

  • Watch the clock. macOS makes it easy to open lots of apps and keep them running. If you’re low on RAM and you notice that you haven’t used a given app in more than an hour, consider quitting it. (To automate the process, try a free app called Quitter for Mac, which can quit any designated app after a user-specified period of inactivity.) It might take a bit longer to reopen that app the next time, but you’ll probably more than recover that time in increased performance due to the extra RAM. (If you want to speed up app opening dramatically, get an SSD; see Add an SSD.)

  • Check your preferences. Many apps can optionally reopen at launch whatever windows, tabs, or documents were open the last time you used the app. (This is the behavior Apple prefers, although not all apps offer this feature.) Doing this can save you time and bother, making it more convenient to quit and reopen apps instead of leaving them running. Check the preferences for your commonly used apps, and enable this feature if it’s offered.

Reduce the Number of Desktop Icons

Are you the sort of person who keeps lots of icons—not counting hard disks, network volumes, and removable media—on your desktop? I know people who regularly have dozens or even hundreds of icons on their desktop, using it as a catchall for downloaded files, work in progress, email attachments, and everything else that needs a temporary home. If that sounds like you, be aware that macOS considers every icon on your desktop a window, and, because every window uses additional RAM, more desktop icons means greater RAM usage.

I can think of lots of other reasons to avoid having too many icons on your desktop, and I talk about these—along with numerous suggestions for changing your work habits to keep those icons elsewhere—in Take Control of Maintaining Your Mac. However you go about doing it, though, I urge you to reduce your total number of desktop icons to as few as possible. Every little bit helps!

Watch Out for Memory Leaks

When an app needs some RAM to accomplish a particular task, it asks the system for that memory. Ordinarily, once the app no longer needs the memory, it hands it back to the system to be used by other apps. For example, an app might ask for more RAM when you open a new window, but when you close the window the app should release that RAM. When an app fails to give back RAM it’s no longer using, it has what’s called a memory leak.

If the failure to give back RAM were a one-time occurrence, and if the amount were small, this situation would be no big deal. The problem is that apps with memory leaks tend to keep requesting more and more memory (perhaps even memory they don’t truly need in the first place) and refuse to give it back, so over time the app’s memory use grows continually, out of proportion to the work it’s doing. Metaphorically, it’s as if there’s a hole in the app that allows the system memory to leak in. The memory keeps collecting until the app uses up so much of your physical and virtual memory that it crashes, or your Mac grinds to a halt.

When you’re already running low on RAM, the last thing you need is to have an app misbehave in this way. Unfortunately, memory leaks are extremely common, because they can be tricky for a programmer to identify and fix. Even the biggest, oldest, and most widely used apps can suffer from memory leaks.

In addition, memory leaks are by their nature slippery. You might observe something that suggests a possible memory leak but that turns out to be entirely correct behavior, and you might have a memory leak that goes unnoticed for months or years because it’s small, subtle, or happens only in rare circumstances.

Still, you can get a good idea whether an app has a memory leak by doing the following:

  1. Open Activity Monitor (see Use Activity Monitor), click the Memory tab, and sort the process list by Memory, in descending order.

  2. Identify a process you want to check—presumably one that’s already using a significant amount of RAM—and make a note of how much real memory it’s currently using.

  3. Leave the app running idle in the background. Don’t open any new windows, perform any actions, or let it perform any obvious background tasks (such as playing music or videos).

  4. Check the app’s Memory column again every five minutes or so for a half hour. If the number consistently goes up more than a trivial amount, that app likely has a memory leak.

  5. Open several new documents (or webpages), and again take note of the Memory figure, which should have increased. Then close the newly opened windows or tabs, and see if the app’s memory usage decreases to approximately its previous level. If it does, that’s a good sign; if not, there may be a memory leak.

Unless you’re a developer with access to an app’s source code, you can’t fix a memory leak. The best you can do is to report your symptoms to the developer and hope they can figure out how to solve the problem at the source. However, you can work around most memory leaks by quitting the process in question, which releases all the memory the process was using. Of course, when the process runs next, the memory leak may occur again, so your only real defense, short of a software update that fixes the leak, is to periodically quit the process.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset