3 ms·
> a GC can be more efficient than direct heap allocations Unoptimised, naive allocations perhaps. I'm old enough to still remember when Microsoft used similar
by viktorcode 4y ago
> a GC can be more efficient than direct heap allocations
Unoptimised, naive allocations perhaps. I'm old enough to still remember when Microsoft used similar line of reasoning to create artificial cases where C# beat C++ performance.
- mypalmike 4y agoI would wager that the majority of C/C++ codebases (e.g. internal business code) use naive allocation. In C++ particularly, naive allocation (I might define this as straight up "has-a" ownership-based heap allocations and deletions) is considered best practice by many.
- kgeist 4y agoNot only that, shared_ptr is also popular in such codebases, and shared_ptr usually has an additional allocation to store reference count in the "control block".
- cogman10 4y agoshared_ptr is nothing more than low latency GC that can't handle cycles. It's the extreme end of the latency throughput tradeoff.
- pjmlp 4y agoGiven that most C++ code in modern Windows applications is for jungling COM instances, no need for artificial cases when every couple of lines there is a Release() or AddRef() call, with possible OS IPC in the middle.