How to optimize virtual memory (swap file) in Windows

Virtual Memory optimizationWindows operating system is using part of your hard drive as a virtual memory. When Windows runs out of physical memory it starts to swap out data to virtual memory, which is a file on hard disk (pagefile.sys). Hard disk is much slower than physical memory, so when Windows start using virtual memory everything slows down. Remember those moments when Windows stops responding and hard disk light is always on…

One solution is to add more physical memory; other is to optimize virtual memory.

Optimizing virtual memory

1. Right click on “My Computer” icon on your desktop and select “Properties”

2. In “System Properties” select “Advanced” tab and click Performance “Settings” button

System Properties - Performance Settings

3. In “Performance Options” select “Advanced” tab and click Virtual Memory “Change” button

Performance Options - Advanced tab

4. “Virtual Memory” settings dialog will appear

Virtual Memory settings

By default virtual memory is located on drive where Windows operating system is installed. If you have more than one partition or disk, you can enable virtual memory on each one independently.

Possible settings are:

Custom – you specify manually minimum and maximum paging file size

System managed size – system determines best size depending on memory requirements

No paging file – paging file is disabled

Best paging file size is three times amount of physical memory (e.g. if you have 512 MB ram, paging file should be 1536 MB), and you should make it fixed size. You can do that by selecting “Custom size” and entering for both minimum and maximum the same size (3 x ram) and click “Set” button.

If minimum and maximum is different size or “System managed size” is selected, paging file can shrink and grow. This is a bad thing, because paging file will become fragmented. More the paging file is fragmented, system will access it slower.

Defragmenting the paging file

If you have defragmentation application like Norton Utilities or Diskkeeper you can use it to defragment paging file. Disk Defragmenter that is included with windows cannot defragment paging file.

You can defragment paging file even if you don’t have necessary application. First, you disable paging file or move it to another partition or disk. Then defragment disk ([how do I do that->how-to-defragment-a-hard-disk-in-windows]) where paging file used to be. After defragmentation is finished, reenable paging file on that defragmented disk.

To summarize:

– Best paging file size is fixed size three times amount of ram (“Custom size” option with same minimum and maximum)

– If you have two physical hard disks put paging file on the one that does not have Windows installed on it

– Defragment your paging file

21 thoughts on “How to optimize virtual memory (swap file) in Windows”

  1. Thats Nice to hear about good pagefile optimization comments . but there is one more thing consider page file in windows xp . Windows Xp Pages its Some of Process By default . It is Necessory to Mention about how to disable that if you have more than 512 mb of ram .

  2. This does not entirely makes sense.

    Say you have a newer system with 2/4/8gb of ram (which many these days do) are you saying that 16gb of page file is necessary?
    Even with my own experimentation I have found that excessively large min sizes causes excess HDD activity, and that an ultra-low min is good to keep things faster.

    On my current system the best I could manage was a 100-2000mb file located on a separate partition on my OS install drive, and a 100-4000mb file on an independent partition on an independent HDD. This gives me blisteringly fast startup times, and relatively fast OS operation. The only downside is that, when running very large games, many files are paged to the second HDD, and the OS has a hard time on termination of the game as there are large amounts of data that have to be erased and re written across separate drives.

    However I wonder if this is still not faster overall than a single file on the OS install drive.

    Aren\’t there any better page file guides than this??? RAM x3 formula sucks, there is so much much much more that can be played around with to get page files working faster.

  3. can any body give answer for these ( swaping is part of virtual memory or physical memory)

  4. YOU HAVE GOT SOME KIND OF CLASS IN THIS SITE. Good to see you up and around!

  5. good info as for Disable mic say no i have 1 PC with XP & 2000MB Ram Page off it say 500mb some times will go to 1300mb set at 4000mb Page file 2 Hard disks Page on #2 fat 16 * 4000mb just for Page file only. looks like more ram window just take it all & go look for more. you can change settihg in reg to help it used ram still like page fist Hard drive min is 2mb for event viewer
    with this pc Page file is set min 500mb max 4000mb as for PC with 512 mb I now set to 1536 mb.

  6. i have 256 mb DDR2 533 Mhz ram. I am going to add 512 mb ram to it. my current initial size is 336 mb and maximum size is 672 mb in custom size in virtual memory dialog box. To which value should i set it now and after buying 512 mb ram? please help.

  7. I have an Athlon XP 64 3200+ (2.21Ghz) 1GB DDR2 system memory. I\’ve been having a lot of memory crash dumps. I\’ve read several forum postings on people who have at least 1GB of RAM disabling the paging file. I\’m clueless when it comes to system type optimization. If I disable the paging file, would have fix the system crash dumps I\’ve been having? Any comments or replies would be appreciated. Thanks.

  8. There is no fixed rule for the optimum value for pagefile minimum size. Setting it at 3 times the size of physical memory may not be enough if memory is short. On the other hand this may be far more than needed if you have 2GB or more. The optimum can only be found through experience with your own memory needs. The optimum will be somewhat above what will meet normal requirements. Windows will give warnings when this lower limit is exceeded. On no account should the minimum be lower than the size of physical memory.

    There is no need to set the upper and lower limits the same. By deafult Windows uses a semi-fixed pagefile. The lower value should be sufficient for normal needs while the upper should be much higher to handle unusual cases or you have set the lower value too low. Unless the lower value is exceeded there will be no pagefile resizing and no pagefile fragmentation. If the lower value is properly chosen this will not happen very often. Setting the lower and upper values the same will risk setting it to small or waste a great deal of disk spce.

    Pagefile fragmentation is not a serious performance issue except in extreme cases. Unlike many other files, the pagefile is not read serially. The pagefile is normally read in realtively small chunks and mixed with other file accesses.

    Larry Miller
    Microsoft MCSA

  9. Hi im trying to play a game called Juiced but when i click on the exe it says Virtual memory must be enabled…how do i do this please.??

  10. I do not know the spot you might be taking your data, even so beneficial issue. I must spend an afternoon mastering considerably more and also determining a lot more. Thanks for outstanding details I used to be hunting for this info for my quest.

  11. I simply could not leave your website prior to suggesting that I extremely enjoyed the usual info a person supply to your guests? Is gonna be back incessantly to inspect new posts

  12. this is very useful website this is very helpful website to find out different versions of operating systems and computer accessories etc.

    thanking you and best regards

  13. Woah! I’m really enjoying the template/theme of this blog.
    It’s simple, yet effective. A lot of times it’s very difficult to get that “perfect balance” between superb usability and
    visual appeal. I must say that you’ve done a great job
    with this. Also, the blog loads super fast for me on Firefox.
    Excellent Blog!

Leave a Reply

Your email address will not be published. Required fields are marked *