logoalt Hacker News

dijittoday at 12:39 PM1 replyview on HN

Also the way memory allocation in Windows works is that if it doesn't actually have the physical RAM (extended by pagefile) then the program will crash.

If you disable pagefile (like I did for some of my servers) and your program mallocs more than what you have in available space (even without ever dirtying a page) you will observe this.

I'm sure that this helps Windows a lot, even if it's not counted as actually used until the page is dirty.

Linux programs very often have virtual addresses many times the amount of physical ram, because there's never been any restriction. It's then very easy to just malloc huge chunks and use what you need and don't care about it too much.

Especially with many "tiny" allocations, python for example has huge sized objects which consume gobs of RAM dynamically, so any long running python process not only fragments memory but ends up having a bunch of objects consuming virtual memory...

idk why I felt the need to rant about this, but it's a difference that I've noted.


Replies

wongarsutoday at 12:52 PM

Yes, Windows doesn't overcommit memory. In the default config Windows is allowed to grow the page file as much as it wants, and empty pages are cheap to reserve in the page file (no need to actually write those zeros, you just need to reserve space for them). So the end effect is comparable, with the difference that software shouldn't just go ahead and ask for gigabytes of memory it doesn't actually need

I prefer the Windows approach, it's more predictable and has better behavior under memory pressure. But it can cause issues with software written under the assumption that the OS uses memory overcommit