Re:A Programming Idiom You've Never Heard Of
by dpark on Wednesday January 04, 2012 @12:05PM
(#3424861)
Reference counting is also not free by itself (ignoring its cycle problems). There's overhead to all the incrementing and decrementing. It can add up in modern systems that toss around objects willy-nilly. Reference counting also adds a ton of additional synchronization points in a multi-threaded scenario.
Re:A Programming Idiom You've Never Heard Of
by bunderbunder on Wednesday January 04, 2012 @01:46PM
(#3425292)
Yup. I don't think it's any coincidence that the only really prominent place where ARC is being used is iOS.
It's a platform where reference counting was already in place, where you can have a reasonable hope that most the programs are too small and simple to take much of a hit on the overhead, and where memory leaks can't get too far out of hand because the OS reserves the right to kill processes whenever it wants.
Re:A Programming Idiom You've Never Heard Of
by masklinn on Wednesday January 04, 2012 @02:38PM
(#3425522)
> where you can have a reasonable hope that most the programs are too small and simple to take much of a hit on the overhead
What overhead? There's no runtime overhead to ARC compared to manual reference counting.
If a reference cycle happens then the only good way to detect that the objects involved have been orphaned is to walk the object graph. Doing that every time an object is deallocated would be horribly inefficient. Also, if you're doing it then there's really no need for the reference counting in the first place, since the object graph walk is perfectly capable of finding all the orphan objects on its own. Much better to just do it periodically, so you can get a whole swath of objects each time you walk the graph.
At which point we've come to to garbage collection, and discovered why that's what all the kids are doing these days.