Out-of-memory
   HOME

TheInfoList



OR:

Out of memory (OOM) is an often undesired state of computer operation where no additional memory can be allocated for use by programs or the operating system. 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. This usually occurs because all available memory, including disk
swap space In computer operating systems, memory paging is a memory management scheme by which a computer stores and retrieves data from secondary storage for use in main memory. In this scheme, the operating system retrieves data from secondary storage ...
, has been allocated.


History

Historically, the out of memory condition was more common than it is now, since early computers and
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
s were limited to small amounts of physical
random-access memory Random-access memory (RAM; ) is a form of computer memory that can be read and changed in any order, typically used to store working Data (computing), data and machine code. A Random access, random-access memory device allows data items to b ...
(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 In computing, virtual memory, or virtual storage is a memory management technique that provides an "idealized abstraction of the storage resources that are actually available on a given machine" which "creates the illusion to users of a very l ...
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 MS-DOS ( ; acronym for Microsoft Disk Operating System, also known as Microsoft DOS) is an operating system for x86-based personal computers mostly developed by Microsoft. Collectively, MS-DOS, its rebranding as IBM PC DOS, and a few ope ...
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 In computing, mmap(2) is a POSIX-compliant Unix system call that maps files or devices into memory. It is a method of memory-mapped file I/O. It implements demand paging because file contents are not immediately read from disk and initially use no ...
(on
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
-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. As predicted by
Moore's law Moore's law is the observation that the number of transistors in a dense integrated circuit (IC) doubles about every two years. Moore's law is an observation and projection of a historical trend. Rather than a law of physics, it is an empir ...
, 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().


Out of memory management

The kernels of operating systems such as
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which ...
will attempt to recover from this type of OOM condition by terminating one or more processes, a mechanism known as the ''OOM Killer''. Linux 4.6 (released in May 2016) introduced changes in OOM situations, improving detection and reliability.,
cgroup cgroups (abbreviated from control groups) is a Linux kernel feature that limits, accounts for, and isolates the resource usage (CPU, memory, disk I/O, network, etc.) of a collection of processes. Engineers at Google started the work on this ...
awareness in OOM killer was implemented in Linux kernel 4.19 released in October 2018, which adds an ability to kill a cgroup as a single unit. Due to late activation of ''OOM Killer'' on some Linux systems, there are several daemons and kernel patches that help to recover memory from OOM condition before it was too late. * earlyoom * nohang * PSI (pressure stall information) kernel patches and the accompanying oomd daemon, the patches are merged in Linux kernel 4.20.


Per-process memory limits

Apart from the system-wide physical memory limits, some systems limit the amount of memory each process can use. Usually a matter of policy, such a limitation can also happen when the OS has a larger address space than is available at the process level. Some high-end
32-bit In computer architecture, 32-bit computing refers to computer systems with a processor, memory, and other major system components that operate on data in 32-bit units. Compared to smaller bit widths, 32-bit computers can perform large calculation ...
systems (such as those with Physical Address Extension enabled) come with 8
gigabyte The gigabyte () is a multiple of the unit byte for digital information. The prefix ''giga'' means 109 in the International System of Units (SI). Therefore, one gigabyte is one billion bytes. The unit symbol for the gigabyte is GB. This defini ...
s or more of system memory, even though any single process can only access 4 GB of it in a 32-bit flat memory model. A process that exceeds its per-process limit and then attempts to allocate further memory will encounter an error condition. For example, the
C standard function The C standard library or libc is the standard library for the C programming language, as specified in the ISO C standard.ISO/IEC (2018). '' ISO/IEC 9899:2018(E): Programming Languages - C ยง7'' Starting from the original ANSI C standard, it was ...
for allocating memory,
malloc C dynamic memory allocation refers to performing manual memory management for dynamic memory allocation in the C programming language via a group of functions in the C standard library, namely , , , and . The C++ programming language includes ...
()
, will return NULL and a well-behaved application should handle this situation.


References


External links


Linux OOM Killer
*Article

by Greg Nakhimovsky *Article
Taming the OOM killer
by Goldwyn Rodrigues *Article

by Mulyadi Santosa *Paper

by John Boyland {{Error messages Memory management Computer error messages