4 ms·
I still wonder how they did that. The classic problem with reference counting is correctly releasing cycles, which ARC handles by allowing "weak" references.
by webjprgm 14y ago
I still wonder how they did that. The classic problem with reference counting is correctly releasing cycles, which ARC handles by allowing "weak" references. How does MacRuby know when to insert a weak reference as opposed to the usual "strong" reference? If that could be automatically detected, why does Obj-C ARC not automatically do it for you?
- chc 14y ago"Object cycles, when two or more objects refer to each other, are currently not handled by the runtime, but will be in future releases." So, basically, you're stuck with retain cycles right now. My bet is that they implement a way of marking weak references rather than becoming more intelligent than ARC.
- smparkes 14y agoI wonder how big a deal this will be. Relying on GC feels like it goes hand in hand with dynamic languages. I'm used to not having to worry about cycles. Of course, I guess I'm use to not having to worry too much about memory, either ... Weak references aren't a panacea. It's not that uncommon to have cycles where all edges are equally strong. Any social graph ... I use use counts to collect those cycles. ARC doesn't let you use use counts, but you don't have to use ARC everywhere. You do have to access to the underlying use counts ... MacRuby should allow access to that (it's just a standard Cocoa call) as long as it doesn't keep stray retains around that screw up my count balances ...
- chc 14y agoYou can still use counts — you just can't use Foundation's retain count. And I think CoreData is the answer to problems like a social graph. It does its own specialized memory management. But you're right, it's awkward to have to think about it.
- chrismealy 14y agoFiguring when to use strong and weak is the only problem I have with ObjC.