4 ms·
GCs can be more efficient if you alloc/free memory very often. shared_ptr can be quite slow because of the bookkeeping. It can also help bring more consistent p
by fathyb 4y ago
GCs can be more efficient if you alloc/free memory very often. shared_ptr can be quite slow because of the bookkeeping. It can also help bring more consistent performance, ie. one big malloc instead of millions of small ones.
- aidenn0 4y agoI would think destructors would negate some of the performance advantages of GCs, since it's not possible to have zero-cost freeing of objects when destructors exist.
- pebal 4y agoSGCL executes the destructors in a separate thread, so there is no cost to the mutator.
- aidenn0 4y ago> SGCL executes the destructors in a separate thread, so there is no cost to the mutator. Firstly, that's orthogonal to my original point is that, for example, a semi-space nursery can significantly reduce the cost of short-lived allocations (often being faster than malloc/free on such a workload), but only if there are no destructors. Secondly, threads typically share resources so running something on a different thread does not magically cause it to not disturb the mutator. Such a claim makes me start to doubt the "real-time" claim in the title...
- pebal 4y agoDisruption is a lower cost than the cost of executing the destructor by the mutator.