Hacker News new | ask | show | jobs
by charleslmunger 920 days ago
This is not always true - for many GCs, threads need to suspend at least some of the time. If the compiler can't prove a small bound on the iterations of a loop, it needs to insert safe point instructions.

Also depending on the GC, read or write barriers may be required.

Lastly there are circumstances in generational moving GCs where there is extra overhead due to checking to and from space - for example if you attempt a compare-and-set on a reference type, you need extra code to check if your CAS failed due to comparing the from-space and to-space addresses of the same object.

I work primarily in garbage collected languages, and there are many benefits - safety, throughput, easy ABA avoidance in lock-free code - but using a GC carries tradeoffs.