Live data from Hacker News

Malloc Never Fails (2012)

scvalex.net

1–10 of 165 posts

Re: Malloc Never Fails (2012)

#5
Malloc allocates virtual memory. The original article had to issue a correction at the end: "I was wrong about why malloc finally failed! @GodmarBack observes, in the comments, that x64 systems only have an address space of 48 bits, which comes out to about 131000 GB. So, on my machine at least, the malloc finally failed because of address space exhaustion."

Re: Malloc Never Fails (2012)

#7
The title here is just blatantly false; there are certainly some scenarios in which it won't fail, but many in which it will. The author is aware of this since he fixes the claim toward the end:

> To clarify, the surprising behaviour malloc has does not mean we should ignore its return value. We just need to be careful because malloc returning successfully does not always mean that we can use the requested memory.

It's worth pointing out that if you turn overcommit off (https://www.kernel.org/doc/Documentation/vm/overcommit-accou...) you will, in fact, get this guarantee

Re: Malloc Never Fails (2012)

#10
> Section III of this Phrack article is a down to earth description of how the glibc malloc implementation works, if you’re curious.

This is probably outdated, given that it was written in 2009.

Post reply on HN