Will Microsoft Windows 10 overcommit memory?

2

1

Linux OS:es will typically allow overcommit of memory. For example a process can allocate 100GB memory, even though the machine only has 8GB physical memory and no swap.

As long as all the allocated memory isn't actually used, the process will work. If the program tries to use it all, the OOM-killer will kill processes to free up memory.

How does this work in Windows? Will Windows refuse to give processes virtual memory unless it can guarantee that this memory can be backed by actual memory (physical RAM or swap)?

avl_sweden

Posted 2017-03-31T13:20:37.633

Reputation: 151

1Historically Windows has never allowed overcommit and as far as I know this has not changed in Windows 10. Overcommit has it's advantages but also some potentially serious problems. It can cause a process that has done nothing wrong and made only modest memory allocations to crash with no possibility of recovery. Windows designers took the more cautions decision of never allowing overcommit. – LMiller7 – 2017-03-31T18:17:10.447

Thanks! Do you know if this is documented somewhere? – avl_sweden – 2017-04-01T22:36:51.610

1The Microsoft publication "Windows Internals" 6th edition, covering up to Windows 7, describes memory management. Overcommit is not supported. The 7th edition, covering Windows 10, I believe is not yet released. But I am sure as big a change as overcommit would have been mentioned somewhere. These books can be tough reading if you do not have the background. – LMiller7 – 2017-04-01T22:59:48.647

Thanks again! Maybe you could put this as an answer so I can accept it? – avl_sweden – 2017-04-03T07:53:12.253

@avl_sweden you can write an answer youself. This will at least allow closing duplicate questions. – Dmitry Grigoryev – 2017-07-07T18:14:31.790

Answers

3

Answering my own question, as no one else has.

It seems to be the case that Windows will NOT overcommit memory. This is actually a big difference compared to Linux.

Windows will allow a program to allocate more (virtual) memory than there is RAM on the machine, but ONLY if there is enough free disk space to be able to back the virtual memory requested by the program by disk if necessary.

avl_sweden

Posted 2017-03-31T13:20:37.633

Reputation: 151

2Yes, exactly. The Windows "commit limit" is simply the RAM size + the current pagefile size. Windows won't let applications + the OS commit more than that. If pagefile expansion is enabled and a commit attempt would take you above the current limit (but less than would be allowed by the limits on pagefile expansion) the pagefile is automatically expanded to allow the request. – Jamie Hanrahan – 2017-07-21T03:47:49.840

It still needs an OOM killer though, as mine crashed multiple times the past few weeks due to presumably dynamically assigning all my 10 GB free HDD space to Chrome. – Cees Timmerman – 2018-02-06T15:52:27.963

Windows is overcommitting memory for stacks! – Bonita Montero – 2019-10-01T05:45:26.023

Oh, that's interesting! Do you have a link or other reference for this information? – avl_sweden – 2019-10-02T07:15:38.717

0

Not sure if this is relevant, but certain applications will have their memory use limited, like Powershell, and throw these errors unless memory allocation settings are changed. Or you run commands through a separate application, like Spyder.

Llewellyn Hinkes Jones

Posted 2017-03-31T13:20:37.633

Reputation: 1

I wrote a test-program that did a lot of VirtualAlloc-allocations on one side - with these the memory-usage growed -, and created a lot of threads with 1mb default-reservation - and the System-commit grew only as large as the thread's initial stack-pages. – Bonita Montero – 2019-12-07T17:35:48.113