5 ms·
How The Kernel Manages Your Memory
- zwieback 16y agoGreat article, nice graphics. His other articles are very good too. I'd love to see someone explaining the details of memory management for the ARM Linux kernel with the same clarity.
- rw2- 16y agoNice post. But it's Hacker _News_. Not "Hacker _OMG I've found a nice old article_". ;-) February 3, 2009 at 11:35 pm
- beaumartinez 16y ago> What to Submit: [...] If you had to reduce it to a sentence, the answer might be: anything that gratifies one's intellectual curiosity. http://ycombinator.com/newsguidelines.html http://ycombinator.com/newsguidelines.html
- rw2- 16y agoHmmm, nobody seems to understand what ";-)" means.
- scott_s 16y agoWe do. Your post is still noise. This is a valuable article that most people here have not seen - I hadn't, even though I have seen others from this author. Which are all excellent, by the way. I upvoted this submission because I love seeing such detailed systems articles on the frontpage.
- pwelch 16y agoI know you meant it jokingly but I come to Hacker News to find good technical/business posts like this one. Great thing about the internet is there are many old still valuable articles out there, many of which some people have not read yet. What might be an old article to you can still be new to other people.
- jedsmith 16y agoAll great reads: http://duartes.org/gustavo/blog/best-of http://duartes.org/gustavo/blog/best-of I've never heard of this guy, but I like him already. Anybody that can produce documentation of this level of quality for a relatively advanced codebase is a good person to have committing, or even just hanging around.
- pwelch 16y agoI agree, the quality is really good. Thank you for pointing out the "Best of" link. Another hour removed from "productivity" and moved to "always wanted to read about" for my day. =)
- xpaulbettsx 16y agoOne 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.
- 16y ago
- DannoHung 16y agoI love this dude's blog, but I wish he'd actually post more new articles.
- shin_lao 16y agoGreat article. If you want to know more about Windows memory layout here's a couple of great books: http://technet.microsoft.com/en-us/sysinternals/bb963901 http://technet.microsoft.com/en-us/sysinternals/bb963901 http://www.amazon.com/Windows-File-System-Internals-Developers/dp/1565922492 http://www.amazon.com/Windows-File-System-Internals-Develope... (Yes it's about file systems but it's an awesome book about Windows internals) http://www.amazon.com/Windows-Device-Development-Classic-Reprints/dp/0976717522/ref=sr_1_6?s=books&ie=UTF8&qid=1300344720&sr=1-6 http://www.amazon.com/Windows-Device-Development-Classic-Rep...