by mikeash · 11y ago · 0 comments
I've spent many hours chasing corrupted memory due to someone not checking malloc() fail.
I chased code that boiled down to assert( ptr=malloc() ); Guess what happens when NDEBUG is defined?
malloc(-1);
With address space fragmentation, the requested size can be a lot smaller and still fail. With overcommit, you can allocate a ton of memory without using up any RAM.Ah, 21st Century problems.