Answer the question
In order to leave comments, you need to log in
What happens when the RAM is full?
Let's imagine a situation: some program started to load more RAM than it is physically available. Any reason - they forgot to free the memory, we load the entire multimedia, and perhaps there is really so much data and this is normal for certain mega-calculations.
Question: what happens in this case?
Primarily interested in Linux, but I would also like to know how things are on other operating systems.
Answer the question
In order to leave comments, you need to log in
Primarily interested in Linux, but I would also like to know how things are on other operating systems.
If the function could not allocate the requested block of memory, a null pointer is returned.
Specifically for Linux:
1) The program issues a request to allocate additional memory
2) The operating system checks if it can allocate this memory.
3) If memory is available, it is allocated and a positive response is returned to the program.
The subtlety at this stage: in fact, there may not be enough memory. Physically, the memory is not engaged yet.
4) The program writes data to the allocated memory. It is at this stage that free memory can run out.
5) The operating system handles the OOM state (out of memory). To begin with, it tries to free memory by such "bloodless" actions as reducing the size of the file cache, I / O buffers, pushing inactive pages to the swap partition / file, etc.
6) If it was not possible to release the memory "bloodlessly", the OOM Killer is called - the "judge", which forcibly terminates one of the running processes (guided by several criteria) until the OOM state is overcome. The program that caused the OMM state has a higher chance of being targeted than others.
Read more:
https://habrahabr.ru/company/yandex/blog/250753/
https://www.insight-it.ru/linux/2015/chto-stoit-zn...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question