malloc fails with ulimit
Very relevant, because containers are often under what basically is ulimit. Not that you can do much when malloc fails...
Malloc Never Fails (2012)
11–20 of 165 posts
Re: Malloc Never Fails (2012)
#12Another thing to keep in mind, though 32 bit is less and less common over time, malloc would probably fail on a 32 bit process that is out of address space.
Raspberry Pis almost always run 32 bit OSes, so that's a common place to encounter 32-bit.
Re: Malloc Never Fails (2012)
#13The 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…
> if you turn overcommit off
The author said ‘does not always mean’ so giving one condition in which it does doesn’t prove them wrong does it?
Re: Malloc Never Fails (2012)
#14Re: Malloc Never Fails (2012)
#15malloc fails with ulimit
Very relevant, because containers are often under what basically is ulimit. Not that you can do much when malloc fails...
Tell the user they can’t do that operation? Use on-disk storage instead? Re-use memory you already have (such as evicting a cache and taking the memory it already had allocated)? Abandon what you were doing if it was only an optimisation and wasn’t essential (such as allocating memory as part of a speculative execution)? Run a garbage collector and try again?
Lots of options available in some situations.
Re: Malloc Never Fails (2012)
#16malloc fails with ulimit
Very relevant, because containers are often under what basically is ulimit. Not that you can do much when malloc fails...
Re: Malloc Never Fails (2012)
#17malloc fails with ulimit
Very relevant, because containers are often under what basically is ulimit. Not that you can do much when malloc fails...
Re: Malloc Never Fails (2012)
#18> 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.
Re: Malloc Never Fails (2012)
#19The 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…
> does not always mean > if you turn overcommit off The author said ‘does not always mean’ so giving one condition in which it does doesn’t prove them wrong does it?
Re: Malloc Never Fails (2012)
#20Malloc 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."