System pagefile size on machines with large RAM
November 22nd, 2009Irrelevant of the size of the RAM, you still need a pagefile at least 1.5 times the amount of physical RAM. This is true even if you have a 1 TB RAM machine, you’ll need 1.5 TB pagefile on disk (sounds crazy, but is true)
When a process asks for MEM_COMMIT memory via VirtualAlloc/VirtualAllocEx, the requested size needs to be reserved in the pagefile. This was true in the first Win NT system, and is still true today see Managing Virtual Memory in Win32:
When memory is committed, physical pages of memory are allocated and space is reserved in a pagefile.
Bare some extreme odd cases, SQL Server will always ask for MEM_COMMIT pages. And given the fact that SQL uses a Dynamic Memory Management policy that reserves upfront as much buffer pool as possible (reserves and commits in terms of VAS), SQL Server will request at start up a huge reservation of space in the pagefile. If the pagefile is not properly sized errors 801/802 will start showing up in SQL’s ERRORLOG file and operations.
This always causes some confusion, as administrators erroneously assume that a large RAM eliminates the need for a pagefile. In truth the contrary happens, a large RAM increases the need for pagefile, just because of the inner workings of the Windows NT memory manager. Although reserved pagefile is, hopefully, never used, the problem of reserving such a huge pagefile file can be quite serious and needs to be accounted for during capacity planning.
What’s a “pagefile”? Where in the simple statement “give me more memory” you talk about pages or files? Why should that matter? 🙂
Seriously, this behaviour is devious, and I would think quite hard about switching to another OS for the server if I encountered such problems. 🙂
@Dorin: On NT systems the paging file is named pagefile.sys and is often referred to as ‘pagefile’. The decision to back allocation by pagefile reservations is a good decision, inherited from the VMS design afaik. Other virtual address systems have to cope with the same problem on their own terms: http://linux-mm.org/OOM_Killer.
Do you think that the same applies to XP/Vista/7 ?
@Andrei: afaik this applies all NT SKUs (NT 3.51, NT 4.0, 2000, XP, Server 2003, Vista, Win7, Server 2008).
@Remus: there’s no difference between using swap space (which can be enabled) and using pagefile – however, if you are FORCED to use a pagefile, that’s pretty damn awful 🙂
Another thing: if your server is using swap space, you probably wrote your application badly 😉 A server should never use swap space. NEVER. People should learn to respect certain limits when writing applications 🙂
Social comments and analytics for this post…
This post was mentioned on Twitter by TheIceCoMan: System pagefile size on machines with large RAM http://ff.im/-bSwX4…