3 ms·
Yes people have incomplete mental models. Something else people often don't realize is that malloc/free aren't instant. Why is de-referring a large object grap
by native_samples 4y ago
Yes people have incomplete mental models.
Something else people often don't realize is that malloc/free aren't instant. Why is de-referring a large object graph slow, well, mostly because free is slow. Why is free slow, because the internals of a malloc can be rather sophisticated. There is probably locking, there may be internal book-keeping like coalescing free regions inside the heap and so on.
If you look at modern GC benchmark workloads, they're often generating gigabytes of allocations per second. Good luck shoving that much work through a typical malloc! Big companies like Google have had to write their own mallocs for a good reason.
- munificent 4y ago> Something else people often don't realize is that malloc/free aren't instant. True, and the costs vary wildly and are deeply tied into the rest of the memory management strategy. In a copying collector, free() is essentially free: It takes the same amount of time to free 1 object in the semispace as it does 1,000 objects in the same semispace.