64

I just upgraded my Windows 7 machine from 12GB to 24GB RAM - both for running more VMs and for future proofing.

My C drive is an SSD with 129GB formatted size.

I was surprised to find out that the SSD only has 68GB free (most of my files are on D: to G:). Researching I found 24GB of my precious C: SSD are taken up by the virtual memory pagefile in the root.

Do I need such large amounts of virtual memory when I have 24GB or RAM? I bought this size of memory so I'd not have to go to disk.

0

8 Answers 8

52

I have 32GB of system RAM and a 256GB SSD, so I wondered the same thing. It does seems safe to change this, since even the dialog itself, at System Properties | Performance Options | Virtual Memory indicates:

Total paging file size for all drives

  • Minimum allowed: 16 mb
  • Recommended: 7,676 mb
  • Currently allocated: 32,768 MB

When defaulted to "system managed size", it was at the maximum of 32768 equivalent to memory size.

I changed it to the "recommended" value so it is now set to range between 7676 - 32768 instead of fixed at 32768:

Virtual Memory page file settings

I'll have to reboot and see if this helps. Edit: rebooted, confirmed, pagefile is now 7GB instead of 32GB. Success!

Since the "why have a paging file at all with that much memory" argument always comes up, it is advisable to have some page file, for the reasons that Mark Russinovich outlines:

Perhaps one of the most commonly asked questions related to virtual memory is, how big should I make the paging file? There’s no end of ridiculous advice out on the web and in the newsstand magazines that cover Windows, and even Microsoft has published misleading recommendations. ...

Some feel having no paging file results in better performance, but in general, having a paging file means Windows can write pages on the modified list ... out to the paging file, thus making that memory available for more useful purposes (processes or file cache). So while there may be some workloads that perform better with no paging file, in general having one will mean more usable memory being available to the system (never mind that Windows won’t be able to write kernel crash dumps without a paging file sized large enough to hold them).

That is why I advocate the recommended paging file size, or at least ½ the recommended size if you are absolutely, positively sure the peak commit charge (max real world memory usage) of the apps you typically use fits in the memory you have. Read the section titled How Big Should I Make the Paging File? in that article for more, it is the definitive statement on the matter. If you'd like to read even more, try this excellent Server Fault question.

7
  • 1
    I've checked my computer. It turns out that a long time ago I set the initial size to 16MB and the maximum size to 5,120 MB, on both SSD drives C and D. It's now working perfectly, with currently 32 MB allocated.
    – Avi
    Nov 7, 2012 at 21:27
  • 3
    I recall reading to not have a page file on an SSD because of the write wear issue (or whatever thats called). Has that problem gone away?
    – dkackman
    Nov 7, 2012 at 21:38
  • 1
    Agreed, if there is another drive without space constraints, that sounds preferable for the page file. In any case, when you have 32GB of RAM, unless you routinely run at 98% memory usage, I'd consider eliminating the page file altogether. The system will warn you if you're running low on virtual memory, and you can probably find a couple apps to close. Pagefile is just insurance nowadays. Nov 7, 2012 at 21:41
  • 1
    Another similar change you can make, if you don't use hibernate, is to disable hibernate via the powercfg -h off command (requires administrator / elevated command prompt). c:\hiberfil.sys is roughly equal to the amount of RAM you have by default, so disabling hibernate saves that disk space. However, even though boot time is fast enough with an SSD that you don't need hibernate, I still use hibernate because I like to keep the state of my apps across sessions. Nov 7, 2012 at 22:21
  • 5
    A 1:1 ratio between physical RAM and pagefile size never made sense. It looks like Windows 8 fixes this behavior. My Windows 8 machine has 8GB of RAM and the automatic settings have the pagefile size as 16MB min, 4543MB max, and 1216MB currently allocated. Nov 7, 2012 at 22:21
14

The best advice for setting the Paging File size (of course) comes from Mark Russinovich. On his site he describes how to use his excellent tool SysInternals Process Explorer to determine the optimal Paging File size for your machine:

"So how do you know how much commit charge your workloads require? You might have noticed in the screenshots that Windows tracks that number and Process Explorer shows it: Peak Commit Charge. To optimally size your paging file you should start all the applications you run at the same time, load typical data sets, and then note the commit charge peak (or look at this value after a period of time where you know maximum load was attained). Set the paging file minimum to be that value minus the amount of RAM in your system (if the value is negative, pick a minimum size to permit the kind of crash dump you are configured for). If you want to have some breathing room for potentially large commit demands, set the maximum to double that number."

Source: https://web.archive.org/web/20130118041656/http://blogs.technet.com/b/markrussinovich/archive/2008/11/17/3155406.aspx

I have been using this method for years.

1
  • Why not just set the pagefile size to whatever giant size you want (like 100GB) if you have terabytes of SSD space?
    – Twinbee
    Jan 16, 2019 at 23:52
3

Probably you have the initial size of the swap file quite high, Windows tends to use a high value by default because if offers better performance. Put the initial size to a small size (in your case I suppose that "small" are 1 or 2 GB) and maintain the maximum value in 24 GB. (If you note that Windows always grows the file over the initial size you should use a higher value).

The trick here is changing the initial value, not the maximum value. If Windows grows the swap file is because it needs that memory.

3
  • 1
    I do NOT recommend such a hugely variable size on an SSD, because if the wear leveling on your drive is crappy you have the potential to really reduce the lifetime of the drive in the (very unlikely) event you use most of that paging.
    – Shinrai
    Nov 11, 2010 at 15:44
  • 1
    Er, to clarify my comment, my recommendation is generally to make the minimum and maximum sizes the same, so it's a fixed file size. This is also nice on slower platter drives to reduce head thrashing and disk fragmentation. I'd recommend 4GB myself but 2 is probably fine.
    – Shinrai
    Nov 11, 2010 at 16:15
  • Thats why I said "If you note that Windows always grows the file over the initial size you should use a higher value". Since he is trying to save disk space there is no point in using a 4GB initial size if 99% of the time Windows never use more than, say, 1.2 GB. In other situations I would agree with you that is better use a bigger initial size for the reasons you mention. Nov 12, 2010 at 14:30
3

As I have seen some atricles on the Net recommending NOT to delete the swap file, and as I'm convinced that during normal operation that memory is enough, what I resorted to was to move the swap file to my non SSD drive. This is a 2TB drive, so I just left it as "system managed" size.

P.S. I did notice that the swap file IS used when the computer wakes up after sleep.

1
  • How did you notice that? It's completely normal as any paged memory operation can trigger access to the file. And it doesn't take long for the first memory cache miss to occur... Nov 27, 2010 at 0:28
2

It depends on your workload. Run all your programs that you usually run (at maximum load) and check virtual memory usage (e.g. with Process Explorer). Just limit your virtual memory to number there. Even if you do not use any virtual memory at all, leave some of it assigned - it helps with memory dumps and memory-mapped files.

2

Here's a link to Microsofts How to:

How to determine the appropriate page file size for 64-bit versions of Windows

Summary:

Operating system   Min page file size Max page file size
Win7/Serv 2008 R2  1 x RAM SIZE       3 x RAM or 4 GB, whichever is larger
Win 8, 8.1, 2012R2 (1)                3 x RAM or 4 GB, whichever is larger

(1) Depends on crash dump setting Cheers

0

With the faster throughput achieved using SSD technology, the swapfile is a much less critical component. While still essential, it does not need to be a created based on the 1.5x ratio commonly used to determine the size of the swapfile on systems equipped with mechanical drives.

As SSD usage has not become widespread we do not have history to consult when configuring the size of the swapfile in a SSD system. What we do have is an understanding Video applications require more memory than Web Email Clients and there by a graduated scale is available to use to determine possible memory needs. Referencing this against User type, surfer/emailer through hard core gamer and the memory needs may be determined.

Swapfile use on the lower end could be handled by 4gb (and that number could serve as the lower limit for swapfile size). Users running database applications, massive spread sheets and similar software capable of generating high memory usage will need considerably more.

Before needing to make such determinations the management process can be handled by Windows. Allowing the User to review it during normal maintenance cycles to gain insight before making adjustments to increase performance.

1
  • 9
    "With the faster throughput achieved using SSD technology, the swapfile is a much less critical component." This doesn't make sense. Jul 21, 2012 at 1:48
-1

The simple yet not so satisfactorily answer is: It depends. Mainly on your usage of the machine.

If you are able to predict your need for memory it is a common practice for system tuning to customize page file settings. A good estimation can involve the following:

To determine the needed paging file size Mark Russinovich advises to take a look at the "system commit" at maximum load, which can for example be seen with the tool SysInternals Process Explorer. He indirectly advises to user-set custom size. (From this superuser answer, source)

This is from my superuser question, where some people recommend using no page file at all.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .