Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


I 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.


SGCL executes the destructors in a separate thread, so there is no cost to the mutator.


> 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...


Disruption is a lower cost than the cost of executing the destructor by the mutator.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: