4 ms·
One of the most important bits to pull out of this article, is that when you ask the kernel for memory, it doesn't actually do anything other than update its ac
by xpaulbettsx 16y ago
One of the most important bits to pull out of this article, is that when you ask the kernel for memory, it doesn't actually do anything other than update its accounting of available memory and VA space - when you touch the page, you page fault and the kernel actually gives you a physical frame. The NT kernel (and I suspect any other production OS) works the same way.
- scott_s 16y agoThis point is in fact extremely important in understanding the behavior of real systems. The analogy I've used to explain it to students is that a memory map (mmap) or brk operation is like getting building permits from the city. You haven't created new buildings, but you've received permission to do so.
- mcculley 16y agoSome Unixes that are meant to support real-time applications allow you to do an actual allocation. e.g., AIX had PSALLOC=early.
- nitrogen 16y agoSee also mlock and mlockall for an approximation of this: http://linux.die.net/man/2/mlockall http://linux.die.net/man/2/mlockall
- ot 16y agoAFAIK there is a difference between Linux and NT: Linux allows overcommitting, while NT requires that every page has a "backing store", for example a physical RAM page, a swap page or a memory mapped file. Thus when you touch the page, Linux may figure out that there is no memory that page can be mapped to it, but now it is too late because the application "believes" that the memory has been allocated. So the kernel kills the application (or, to be correct, an application) too free memory with an OOM exception. This is one of the reasons why it is good to have loads of swap even if the physical RAM is big enough for all the running processes.
- nitrogen 16y agoOr, if you know you won't be running applications that allocate more than they use, you can disable overcommission entirely.