3 ms·
Does refcounting use less memory than tracing GC? Swift vs. OCaml
- deleted 6y ago[deleted]
- nabla9 6y agoUsually tracing generational GC with copying GC as the last phase is the overall fastest. There can be also mock refcounting in a mix. Typically 0,1, many for some data structures. It's hard to see how Apple/Swift could reverse benchmarks to favour reverence counting unless they use some specific benchmarks.
- Someone 6y agoI think using a different language, so a different compiler with a different level of maturity introduces too many conflating variables to decisively answer this question. I don’t know the answer, either, but believe (corrections welcome) https://people.cs.umass.edu/~emery/pubs/gcvsmalloc.pdf https://people.cs.umass.edu/~emery/pubs/gcvsmalloc.pdf hasn’t been refuted. It says GC needs 5 times the memory as manual memory management for equivalent performance, 3 times the memory for about equivalent performance. Of course, that paper isn’t about reference counting. I think reference counting should see the same alloc/free patterns as manual memory management, but with larger allocation sizes, to accommodate for a reference count in every object allocated. Even if that, on average, doubles the allocation size, that 5 and 3 still would be 2½, respectively 1½. That logic may be broken, but I also notice that iPhones typically have less memory than Android phones, yet seem to do well in reviews. That, too conflates variables, so GCvs Reference Counting may not be a big factor, but if not, what is the reason?