On 9 October 2013 23:06, Michel Fortin <michel.for...@michelf.ca> wrote:
> On 2013-10-09 07:33:29 +0000, Manu <turkey...@gmail.com> said: > > Is there more to it? Cleaning up circular references I guess... what does >> Apple do? >> > > Apple implemented auto-nulling weak pointers for ARC (as well as > __unsafe_unretained ones if you are not afraid of dangling pointers). > > It's an uncommon edge case, so there's gotta be heaps of room for >> efficient >> solutions to that (afaik) one edge case. Are there others? >> > > I don't know about you, but circular references are not rare at all in my > code. > > Another solution that could be used for circular references is to have the > stop-the-world GC we have now collect them. Reference counting could be > used to free GC memory in advance (in the absence of circular references), > so the GC would have less garbage to collect when it runs. > > Both solutions (week-autonulling and last-resort GC) are not mutually > exclusive and can coexist. I suspect there are plenty of creative possibilities that could be applied to reducing the pool of potential circular-references to as small a pool as possible. It's simply not feasible to have machine scanning 4-6 gigabytes of allocated memory looking for garbage.