3 ms·
Exceptions should never be enabled by default. We live in a 64bit world so allocations failing indicates some other problem.
by phkahler 9mo ago
Exceptions should never be enabled by default. We live in a 64bit world so allocations failing indicates some other problem.
- zbentley 9mo agoWhat does processor but width have to do with the likelihood of allocation failures?
- petcat 9mo ago640K ought to be enough for anybody!
- HarHarVeryFunny 9mo agoI think what he means is that on a 64-bit system you have a massive virtual address space (typically only 48-bit, but that's still 256TB), and since malloc allocates from virtual address space, not limited by physical memory, it is unlikely you will get a malloc failure (unless you are trying to allocate more than 256TB per process, maybe due to a memory leak).
- locknitpicker 9mo ago> it is unlikely you will get a malloc failure That assertion completely misses the point. The scenarios involving move constructors throwing exceptions involve objects being stuck in an inconsistent/zombie state. In fact, the whole point of a move constructors is to avoid having to allocate memory.
- zbentley 9mo agoThat's not true as generally as you might expect. Folks might be using mmap with MAP_POPULATE; they might have overcommit turned off; they might be operating in an rlimit/cgroup (like most container runtimes/orchestrators configure) that limits memory; they might be on a system which doesn't have virtual memory (plenty such systems exist in 64-bit architectures); they might be using calloc on an OS that zeros pessimistically/early; and so on.
- usefulcat 9mo agoExceptions can be used to indicate many kinds of errors, not just allocation failures.