3 ms·
> Firefox will all pretty much just crash if malloc() fails It's not nearly as simple as that. A general approach we try to use is the following. - Small allo
by nnethercote 10y ago
> Firefox will all pretty much just crash if malloc() fails
It's not nearly as simple as that. A general approach we try to use is the following.
- Small allocations are infallible (i.e. abort on failure) because if a small allocation fails you're probably in a bad situation w.r.t. memory.
- Large allocations, especially those controlled by web content, are fallible.
The distinction between small and large isn't clear cut, but anything over 1 MiB or so might be considered large. You certainly don't want to abort if a 100 MiB allocation fails, and allocations of that size aren't unusual in a web browser.
- wahern 10y agoThat approach may make sense on the desktop, but it doesn't make sense for network servers. On a network server allocations tend to be small. Your 10,001st request might fail not because of a huge allocation but because it just pushed you over the line. Aborting all 10,000 requests provides really poor QoS. You can get away with that if you're Google, because 10,000 requests is still miniscule relative to your total load across "the cloud". For almost everybody else it will hit hard, and among other things makes you more susceptible to DoS.
- pcwalton 10y agoSo, to be clear, you're implying that you shouldn't write network services in Python, Ruby, PHP, Go, Java in practice [1], Perl, C++ without exceptions, JavaScript, etc. etc.? [1]: http://stackoverflow.com/questions/1692230/is-it-possible-to-catch-out-of-memory-exception-in-java http://stackoverflow.com/questions/1692230/is-it-possible-to...