Jump to content

Is increasing swap space in windows useful?

thomasvice

So I have a friend that has a slow computer with 4 gb RAM, he told me something about "virtual RAM" which to me was as true as downloadable RAM at first. Then I learned all he was doing was increasing the size of the swap "partition" if you can call it that. is there any performance advantage in increasing the swap space when the system has insufficent memory? 

Link to comment
Share on other sites

Link to post
Share on other sites

7 minutes ago, thomasvice said:

So I have a friend that has a slow computer with 4 gb RAM, he told me something about "virtual RAM" which to me was as true as downloadable RAM at first. Then I learned all he was doing was increasing the size of the swap "partition" if you can call it that. is there any performance advantage in increasing the swap space when the system has insufficent memory? 

In practice it could end up being slower than before because you're now using your hard drive as memory. I wouldn't recommend using a SSD for this purpose as there's a lot of little reads and writes done which would shorten the life span of your drive. The only for sure way to increase performance when you have insufficient memory is to... add more memory. The page file is not an elegant solution. 

Intel® Core™ i7-12700 | GIGABYTE B660 AORUS MASTER DDR4 | Gigabyte Radeon™ RX 6650 XT Gaming OC | 32GB Corsair Vengeance® RGB Pro SL DDR4 | Samsung 990 Pro 1TB | WD Green 1.5TB | Windows 11 Pro | NZXT H510 Flow White
Sony MDR-V250 | GNT-500 | Logitech G610 Orion Brown | Logitech G402 | Samsung C27JG5 | ASUS ProArt PA238QR
iPhone 12 Mini (iOS 17.2.1) | iPhone XR (iOS 17.2.1) | iPad Mini (iOS 9.3.5) | KZ AZ09 Pro x KZ ZSN Pro X | Sennheiser HD450bt
Intel® Core™ i7-1265U | Kioxia KBG50ZNV512G | 16GB DDR4 | Windows 11 Enterprise | HP EliteBook 650 G9
Intel® Core™ i5-8520U | WD Blue M.2 250GB | 1TB Seagate FireCuda | 16GB DDR4 | Windows 11 Home | ASUS Vivobook 15 
Intel® Core™ i7-3520M | GT 630M | 16 GB Corsair Vengeance® DDR3 |
Samsung 850 EVO 250GB | macOS Catalina | Lenovo IdeaPad P580

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, thomasvice said:

So I have a friend that has a slow computer with 4 gb RAM, he told me something about "virtual RAM" which to me was as true as downloadable RAM at first. Then I learned all he was doing was increasing the size of the swap "partition" if you can call it that. is there any performance advantage in increasing the swap space when the system has insufficent memory? 

"swap partition" is pagefile.

Pagefile is a hidden file on disk of reserved space, which acts as an extension to the system RAM. This was very useful in the old days, where RAM was super expensive, and we were talking about KB only. Even in the days of early 2000, typically a gaming, expensive system, had only 128MB of RAM. Today, it is still useful, as everything got fancier from OS to programs, and so consumes a lot more RAM.

 

That said, pagefile, isn't a directly link to your RAM. It isn't. What happens, is that it is the OS playing the game or doing transfers of removing what is on AM which is guesses that you don't use (for example, a program that is minimized and not doing any activity), with an activate process, and when you switch, it has to transfer the RAM of the program back to the RAM, and transfer something else back to the drive. Consider that even the fastest SSD in RAID0 is still massively slower than RAM, it is still best to try and avoid having the system use the pagefile.

 

Why not disable it?

If you do this, yes, you'll avoid the system from ever using it. But if you run out of RAM, then your program will crash. So, it is best to have this safety net, even if you have 16GB of RAM in a system. Also keep in mind, that in RAM, the memory inside CANNOT be fragmented nor moved. So, if you open Task Manager, for example, you can fall into a situation where you have 1GB of RAM free (say), but you can't open a program or game due to lack of RAM, despite having 5GB free. This is because, in this example, the program is larger than any available free spot in RAM.

 

In other words:
Imagine you are trying to open a game called "Game A", that consumed 800MB. You have 2GB of RAM (using smaller figures to present the example, in a short visual form), where 1GB is used by programs.

 

Your RAM looks like this.

[ Program A ][ 512MB free space ][ Program B ][ 512MB of free space ]

You have 1 GB of free space. Game A should perfectly fit, being only 800MB. But it can't fit, as you don't have 1 free chunk of 800MB. 

 

This is where pagefile comes in, and allows you to run Game A, where the OS will take the program that it determined you won't use (example: Program B), and move it to your HDD/SSD, then run Game A, then see if there is space to return Program B to RAM, and if there is, do so. So you end up, with the example above:

[ Program A ][ Game A ][ Program B ][ 200MB Free space]

 

So pagefile is useful, even if you have plenty of free RAM.

 

The above explanation is just a quick overview. If you are interested, they are technical books to dives in more in depth.

 

 

So, onto your question. Will increasing pagefile help performance?

No. But it won't hurt it either. By default, the most OSs on the consumer market manages the pagefile itself, and is best to let the OS do it's thing. Typically, modern versions of Windows, will match the pagefile with the amount of RAM you have, effectively doubling your RAM. If you are out of pagefile space and RAM, you'll get Windows telling you that you are running out of virtual memory.

 

If RAM is limited on the system (as in, you see in task manager that the RAM consumption is very high, then the page file could be used, and to enjoy a faster, more responsive system, then increasing the system RAM is the actual fix. Making the pagefile larger, won't help. It will only help running more programs, that is all.

 

What's the solution?

You have 2 solutions:

  1. Buy more RAM
  2. or, Sacrifice a high speed USB flash drive with Windows ReadyBoost feature. This will make the OS, use your USB flash drive instead of your HDD for RAM. This feature will be slower if your pagefile is on your SSD. Also, you should expect an increase in CPU usage, as USB controllers are not independent, they need the CPU to do work for it. It doesn't have a micro-processor in its controller like SATA does. (PCIe drives have both, controller and micro-processor (which is integrated in the controller chip) to handle communications, so, it also doesn't use the CPU)

 

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, BlueChinchillaEatingDorito said:

In practice it could end up being slower than before because you're now using your hard drive as memory. I wouldn't recommend using a SSD for this purpose as there's a lot of little reads and writes done which would shorten the life span of your drive. The only for sure way to increase performance when you have insufficient memory is to... add more memory. The page file is not an elegant solution. 

No.. but yes... Back in Windows XP days and earlier, Windows used a very aggressive algorithm to reduce RAM usage. Remember that back in XP days, your typical system, had 128MB of RAM. A gaming PC and most workstation PCs, had 256MB of RAM. That was very little. So the OS would continuously attempt to move things in pagefile, as if you are always low in memory. That is why big programs that were minimized for a while, took ages to restore. Also, if you were playing a game and quit, it took a long time to get your desktop to show, with your HDD being under heavy load for a moment. This was Windows moving pagefile items back to RAM to be executed by the CPU. Remember, the CPU only has direct access to its internal cache and your RAM. The rest it cannot access, it needs the OS to have stuff form disk moved to RAM to be able to do anything with it.

 

So, back then, when 512B and 1GB of RAM was a thing that can be afforded by the mainstream consumer who still had a thick wallet for them (as it wasn't cheap), the workaround to gain performance, was to disable pagefile at the risk of having program crash, left and right and had to shutdown the PC at the very least once a day (when you are done) to avoid the program of having free RAM, but can't be used problem mentioned in my previous post. It was a desperate move, yes. Not fun when gaming or working on actual things that bring you money and it crashes on you, as you are out of RAM. But, you had a gain in performance. For most people, this was not worth it. But this is where "disable pagefile to gain performance" come from.

 

Since Vista, the OS memory management works completely differently. While it has improved over time in each version of Windows. Under Windows 10, the model is the reverse of Windows XP, where it will favor RAM usage over disk. The focus is on delivering the user the most responsive experience possible. This is also why there was a large gap in memory usage increase between Windows XP to Vista, beside being a much fancier OS, with lost of new features (mostly on the back, but many showed its face when Windows 7 came around). Heck, since Vista we have SuperFetch, that is a system in Windows, which, depending on how much RAM you have, will partially preload applications before you do using prediction algorithm, based on past activity. This is to make applications load faster then you actually do come and run it.

 

Link to comment
Share on other sites

Link to post
Share on other sites

I forgot to mention, that under Windows 10, if you are limited in RAM, the OS would start compressing inactive programs loaded, and decompress them when they are in use. A new system to reduce the use of pagefile, at the expense of CPU load (to handle the compression/decompression part). So if you have an Atom based system (Intel now call them Pentium Silver, at an attempt to sale these garbage chips to consumers who don't know any better), and low in RAM, you are in for baaaaaad time.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×