Out of memory (OOM) is a pathological state of computer operation where all available memory, including disk swap space, has been allocated. Such a system will be unable to load any additional programs and since many programs may load additional data into memory during execution, these will cease to function correctly. Historically, the out of memory condition was more common than it is now - early computers (including personal computers) and operating systems were limited to small amounts of physical Random Access Memory due to low addressability limits and cost considerations, and lacked support for virtual memory on a hard drive (if the system did indeed have one). It was usually a problem with single-tasking operating systems that had the ability to retain multiple programs in memory at once (for example, the terminate and stay resident functionality of Microsoft DOS). At some point, the user would be forced to close some programs before any more could be loaded. Today, the out of memory condition is rare due to the implementation of virtual memory on a hard drive. Operating systems such as Microsoft Windows 95 and later versions, as well as Linux also automatically manage virtual memory usage so that RAM is used more efficiently. Due to 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. It should be noted that, in most cases, a computer with virtual memory support where the majority of the loaded data resides on the hard disk would probably run so slowly due to excessive paging that it would be considered to have failed, prompting the user to close some programs or reboot. As such, an out of memory message is rarely encountered with modern computers. Operating systems such as Linux will attempt to recover from an OOM condition by terminating a low-priority process, a mechanism known as the OOM Killer.
Per-process memory limits
A system may limit the amount of memory each process may use. This is usually a matter of policy but it can also happen when the OS has a larger address space than is available at the process level. It is not uncommon for high-end 32-bit systems to come with 8GB or more of system memory, even though any single process can only access 4GB of it in a 32-bit flat memory model. A process that exceeds its per-process limit will have attempts to allocate further memory, for example with malloc(), return failure. A well-behaved application should handle this situation gracefully; however, many do not. An attempt to allocate memory without checking the result is known as an "unchecked malloc".
See also
External links
- Linux OOM Killer
- Out of Memory handling
- Article "Minimizing Memory Usage for Creating Application Subprocesses" by Greg Nakhimovsky
- Article "When Linux Runs Out of Memory" by Mulyadi Santosa
- Paper "Handling “Out Of Memory” Errors" by John Boyland
- std::bad_alloc Class Reference


