Historically, the out-of-memory condition was more common than it is now, since early computers and
operating systems were limited to small amounts of physical
random-access memory (RAM) due to the inability of early processors to address large amounts of memory, as well as cost considerations. Since the advent of
virtual memory opened the door for the usage of swap space, the condition is less frequent. Almost all modern programs expect to be able to allocate and deallocate memory freely at run-time, and tend to fail in uncontrolled ways (crash) when that expectation is not met; older ones often allocated memory only once, checked whether they got enough to do all their work, and then expected no more to be forthcoming. Therefore, they would either fail immediately with an "out of memory" error (OOME) message, or work as expected. Early operating systems such as
MS-DOS lacked support for
multitasking. Programs were allocated physical memory that they could use as they needed. Physical memory was often a scarce resource, and when it was exhausted by applications such as those with
terminate-and-stay-resident functionality, no further applications could be started until running applications were closed. Modern operating systems provide virtual memory, in which processes are given a range of memory, but where the memory does not directly correspond to actual physical RAM. Virtual memory can be backed by physical RAM, a disk file via
mmap (on
Unix-derivatives) or MapViewOfFile (on Windows), or swap space, and the operating system can move virtual memory pages around as it needs. Because virtual memory does not need to be backed by physical memory, exhaustion of it is rare, and usually there are other limits imposed by the operating system on resource consumption. (For example, Windows uses
commit charge accounting to limit the size of virtual memory.) As predicted by
Moore's law, the amount of physical memory in all computers has grown almost exponentially, although this is offset to some degree by programs and files themselves becoming larger. In some cases, a computer with virtual memory support where the majority of the loaded data resides on the hard disk may run out of physical memory but not virtual memory, thus causing excessive
paging. This condition, known as
thrashing, usually renders the computer unusable until some programs are closed or the machine is rebooted. Due to these reasons, an out-of-memory message is rarely encountered by applications with modern computers. It is, however, still possible to encounter an OOM condition with a modern computer. The typical OOM case in modern computers happens when the operating system is unable to create any more virtual memory, because all of its potential backing devices have been filled or the end-user has disabled them. The condition may arise because of copy-on-write after
fork(). == Recovery ==