1

I've been getting sporadic "Out of Memory" popups while playing games in fullscreen windowed mode lately (namely Arma 3 and BF4). I didn't get these before switching from fullscreen to fullscreen windowed, but it may be unrelated. However, when these warnings pop up, I usually jump into Resource Monitor to have a look at the current state of my system memory, and there's always less than 2GB being used by the game in question, and still 1-3GB still in standby.

Is this normal to have it pop up this early, or is Resource Monitor displaying my available memory wrong (or, do I not understand what the "Standby" portion is)? It appears to be a legitimate issue, because I tend to get notifications of failed memory allocation by other programs at the same time.

I'm running 64-bit Windows 7, and have 8GB of RAM installed.

  • Sometimes **Out-of-Memory** refers to filling most of the memory and the swap file. How big is your swap file? – cybernard Feb 23 '14 at 01:32

1 Answers1

1

You are confusing virtual memory with physical memory. The "out of memory" pop up is reporting a shortage of virtual memory. You can have lots of free physical memory and still have a shortage of virtual memory. The usual solution is to configure a larger paging file.

To use a somewhat simplified analogy, physical memory is like money in the bank, virtual memory is like the balance in your checkbook. You can have plenty of money in the bank, but if the balance in your checkbook is low, you can't safely write any more checks.

A paging file is like a line of credit that you can use to cover checks if you run low on money in the bank. With a line of credit, you can keep writing checks even if the balance in your checkbook is low. The paging file can cover a "run on the memory bank" in the unlikely event all the outstanding checks are cashed at once.

The paging file allows the operating system to keep permitting allocations of virtual memory even if the operating system never has to use it. It ensures that should all the outstanding allocations of virtual memory require physical memory all at once, the operating system won't be forced to break the promises it has already made.

David Schwartz
  • 61,528
  • 7
  • 100
  • 149
  • By the way, I believe in your case the virtual memory consumption is caused by a bug. – David Schwartz Feb 23 '14 at 03:09
  • A bug on whose end? Windows, or a program? Thanks for the info, by the way. Shouldn't Windows just use RAM when the page file is going to overflow? – Gabriel Chiarelli Feb 23 '14 at 03:12
  • A bug caused by windowed full-screen mode, likely in the graphics driver. As for your second question, that can't work. There's no guarantee there will be free RAM later when the page file is in danger of overflowing, so we can't rely on it now. – David Schwartz Feb 23 '14 at 03:16
  • So what determines what goes into the page file vs physical memory? I suppose I'm not fully following the analogy, but I'm currently studying in a computer programming field, so I should be able to understand a more specific explanation. – Gabriel Chiarelli Feb 23 '14 at 03:25
  • EDIT: Never mind, it just clicked. If I'm getting it now, the memory marked "Standby" in Resource Monitor is memory that has been paged, but is not actually being accessed. So if I have ~5GB in use, and >2GB in standby, then I actually have <1GB available. Then it reaches into the page file, and eventually overflows because it's too small. So adding more RAM should relieve the page file usage and stop the overflows, or I could increase the page file at the expense of performance (potentially). – Gabriel Chiarelli Feb 23 '14 at 03:31
  • @GabrielChiarelli Not quite. The RAM in standby is available. There is no RAM shortage. The shortage is *virtual memory*. The problem is that RAM has already been promised to applications (that likely will never use it). So the operating system can't keep promising more memory than it has. – David Schwartz Feb 23 '14 at 04:41
  • @GabrielChiarelli For example, say an application makes a private, writable memory mapping of a 2GB file. That *could* consume up to 2GB of physical RAM at any time, but it likely never will. The OS must reserve 2GB of backed memory for that mapping even though it will likely never need very much of it. – David Schwartz Feb 23 '14 at 04:43
  • Yeah, that's what I meant. The RAM in standby isn't being accessed, but is held by a process. Therefore it is effectively used up as far as allocating memory for other programs is concerned. The shortage of virtual memory happens because there is not enough unallocated space on RAM, so Windows starts allocating virtual memory. Right? – Gabriel Chiarelli Feb 23 '14 at 04:55
  • @GabrielChiarelli It can occur even without that though. Consider a modifiable, private memory mapping. Until it is used, it requires no physical RAM at all, standby or otherwise. But backed virtual memory must be reserved for it. Most standby memory is unbacked, and so the data can simply be discarded. – David Schwartz Feb 23 '14 at 05:04
  • Ah, I see. It's hard to find detailed information of how the Windows page file is used, thanks. – Gabriel Chiarelli Feb 23 '14 at 05:22
  • @GabrielChiarelli No, it isn't hard to find. It's in the _Windows Internals_ book. But it's not a short read, even just the memory management parts. – Jamie Hanrahan Jul 21 '15 at 05:12
  • @GabrielChiarelli _"The RAM in standby isn't being accessed, but is held by a process. Therefore it is effectively used up as far as allocating memory for other programs is concerned. ... Right?"_ **NO!** It is not "held by a process" and is just as easy to allocate for new use as "Free" or "Zeroed" RAM. – Jamie Hanrahan Jul 24 '15 at 22:38