4 ms·
But how many times the problem truly happened? Is in my experience so rare that the experience is alike with a GC.
by mamcx 8y ago
But how many times the problem truly happened? Is in my experience so rare that the experience is alike with a GC.
- giornogiovanna 8y ago- Doubly linked lists. - Cocoa delegates that keep references to some parent of the objects that they're delegates of. - Some event listeners (in the same way as delegates). I wouldn't say it's "rare". It popped up pretty often for me when I was writing Objective C.
- azinman2 8y agoWhat’s not solved with weak refs?
- giornogiovanna 8y agoIt can always be solved with weak references.
- fauigerzigerk 8y agoOnly if you know that you haven't solved it already: https://news.ycombinator.com/item?id=19093677 https://news.ycombinator.com/item?id=19093677
- ben-schaaf 8y agoWhat's not solved with manual memory management? The point is not that you can't solve it, the point is that reference counting isn't the whole solution for garbage collection unlike a tracing gc for instance.
- saagarjha 8y agoWeak reference counting is still reference counting.
- int_19h 8y agoIt depends on your domain. Any data structure that has links in both directions becomes a pain, and it's pretty common to have trees like that. It's usually solved by having parents own the children but not vice versa, but then you run into cases where you want the whole thing to live so long as someone holds an owning reference to a child.
- mamcx 8y agoAgree. Is similar on rust, where circular links are also hard to do. Easy graphs is a killer feature of a GC. But also, is a localized problem. I have more issues with obj-c in the past, some ergonomic of swift make it even rarer. However, certainly suck for the ones that hit this!. I'm building a relational lang in rust and damm, I miss a GC!
- zozbot123 8y agoMany people in the Rust community use some sort of ECS in cases where something like a GC is needed. The whole point of ECS is that they work a lot like an ordinary GC runtime or an in-memory database, the underlying representation ensures that the system knows about all the "entities" that it needs to, and can reliably trace linkages between them. It might be easier to just use Go in cases where tracing GC is needed, though.
- Buttons840 8y agoI've only heard of using ECS for games. I'll have to look into them more closely.
- azinman2 8y agoWhen would you want the graph to exist due to some leaf more being retained but you wouldn’t know about it enough to maintain a ref to the root mode?
- int_19h 8y agoIn a language with tracing GC, you'd use a strong reference in both directions, so anybody who holds the child can always walk their way to the root (if you expose those references). Without such GC, you basically have to pass the root around, because it's what's holding all those children alive.
- pjmlp 8y agoAlike a tracing GC..,.