According to an old rule of thumb, your page file or swap should be “double your RAM” or “1.5x your RAM.” But do you really need a 32 GB page file or swap if you have 16 GB of RAM?
You probably don’t need that much page file or swap space, which is a relief considering a modern computer might have a solid-state drive with very little space.
The Purpose of the Page File or Swap Partition
First, let’s remember the real purpose of the page file on Windows or swap partition on Linux. Both provide additional working memory to your computer. For example, if your computer has 2 GB of RAM and you open a large number of programs or large number of files, your computer might need to store 3 GB of data in its working memory. The computer stores that additional 1 GB of data in its page file or swap space. The page file or swap acts as an “overflow” area to hold the additional data. Your computer automatically transfers data back to its RAM when it’s being used, and moves data to its page file or swap partition when it’s not being used.
If you used an older desktop computer, you could see this happen after you minimized a desktop program for a while. When you maximized it later, it would take a while to appear, and you’d hear your hard drive grinding away while that disk activity LED flashed — its data was being moved back from your page file or swap partition to its RAM. The RAM is much faster than the page file or swap partition. (This is much less common on modern computers that have sufficient amounts of RAM to keep desktop programs in RAM.)
Most applications expect to get the memory they request. If your RAM was full and you had no page file, and then you opened another program, the program would likely crash. Having a page file with additional space programs can use prevents this from happening.
Other Uses for Page File and Swap Partitions
Windows and Linux also use their page file and swap space for other purposes:
- Windows Crash Dumps: On Windows, the page file is used for crash dumps. To create a complete memory dump, the page file must be at least the size of the physical memory + 1 MB. For kernel memory dumps, the page file must be at least 800 MB on systems with 8 GB of RAM or more. Most people won’t need complete memory dumps, but kernel dumps might be useful. The required 800 MB page file is fairly small, but it requires you leave your page file enabled and don’t disable it. (This information is taken from the Understanding Crash Dumps post at Microsoft TechNet.)
- Linux Hibernation: On Linux systems, hibernate — the power-down state that saves the contents of your system’s RAM to disk so it can be reloaded when you boot up again — saves the contents of the system’s RAM to the swap partition. This may also be referred to as “suspend to disk.” You might assume you need a swap partition as big as your RAM to hibernate to it, but you actually just need a swap partition as big as the RAM you use — so, if you only regularly use 4 GB of your 16 GB of RAM, you could hibernate to a 4 GB swap partition. However, if you used more than 4 GB of RAM, you might not be able to hibernate. It’s often safe to choose a swap partition equal to the size of your RAM. Note that this only applies to hibernating — if you never plan on hibernating your computer, you don’t need to worry about this. (Windows hibernates by saving data to the C:\hiberfil.sys file, so the page file isn’t involved when hibernating on Windows.)
The Real Question: How Much Memory Do You Use?
There’s no one hard-and-fast rule that will tell you how much paging or swap space you need. The answer depends on what you do with your computer and how much memory you use. For example, if you have 8 GB of memory but you never ever used more than those 8 GB, you could get by with no paging or swap space at all — it’s likely you would need more than 8 GB eventually, of course. On the other hand, you might have a computer with 64 GB of memory, but it might regularly work with 100 GB data sets — you’d probably want at least the 64 GB paging or swap space just to be safe. So a computer with 8 GB of RAM might need no page file and a computer with 64 GB of RAM might need a huge page file. It all depends on what the computer is doing.
Most people won’t be able to predict how much paging or swap space they need. Even if you looked at your used memory right now, there’s no telling how much your programs will need in a week or a month.
Windows Can Automatically Manage It
On Windows, the page file is stored at C:\pagefile.sys. By default, Windows automatically manages the size of this file. It starts small and grows to a potentially larger size if you need it. We recommend letting Windows handle the size of the page file on its own. It shouldn’t take a massive amount of space on your system drive. If your page file does take a large amount of space on your system drive, it’s because you needed that large a page file in the past and Windows automatically grew it in size for you.
For example, on a Windows 8.1 system with only 4 GB of RAM, our page file is currently only 1.8 GB in size. We don’t have all that much RAM, but Windows is using a small page file until we need more.
There are no performance benefits to getting rid of a page file, only potential system instability issues where programs might crash if you use all your RAM. You could eliminate the page file to save space on your system drive, but it usually isn’t worth it.
If you want to manually set a size — not recommended — be sure to bear in mind that what really matters if how much memory your system will use, not just the size of its RAM. Microsoft’s documentation notes that:
“the reason to configure the page file size has not changed. It has always been about supporting a system crash dump, if it is necessary, or extending the system commit limit, if it is necessary. For example, when a lot of physical memory is installed, a page file might not be required to back the system commit charge during peak usage. The available physical memory alone might be large enough to do this.”
In other words, it’s all about how much memory you’ll actually need — the total amount of available memory being the “system commit limit.”
Linux Requires a Choice
On Linux, the equivalent to the Windows paging file is the swap partition. Because this is a partition and not just a file, you have to make a choice about the size of your swap partition when installing Linux. Sure, you could resize your partitions later — but that’s more work. Linux can’t automatically manage the size of your swap partition for you.
Each Linux distribution uses its own installer, and each Linux distribution has some logic in its installer that automatically tries to choose the appropriate swap partition size. Linux distributions typically use the size of your RAM to help decide the size of your swap partition. When installing Ubuntu, the typical default swap partition size seems to be the size of your RAM plus an additional half a GB or so. This ensures hibernate will work properly.
If you’re manually partitioning in your Linux installer, the size of your RAM plus .5 GB is a good rule of thumb that will ensure you can actually hibernate your system. That should usually be more than enough swap space, too. If you have a large amount of RAM — 16 GB or so — and you don’t need hibernate but do need disk space, you could probably get away with a small 2 GB swap partition. Again, it really depends on how much memory your computer will actually use. But it’s a good idea to have some swap space just in case.
The old “double the size of the RAM” rule of thumb applied to computers with 1 or 2 GB of RAM. There’s no one-size-fits-all answer to how much page file or swap space you need. It all depends on the programs you use and what they need. If you’re unsure, sticking with your operating system’s defaults is almost always a good idea.
- › How to Hear a Chime When Google Assistant Speakers Are Listening
- › Use Google to View 3D Pac-Man and Anime Characters on Your Phone
- › How to Show the Number of Unread Gmail Emails in Your Browser Tab
- › How to Turn off Start and End Workout Notifications on Apple Watch
- › How to Add an App to the Dock on a Mac