Earlier quoted context omitted.
I don't see your point. Of course sometimes the lifetime of an object is not tied to code scope but actually to something dynamic. Let's say for instance when you close a tab in your browser you expect the resources to be freed (ignoring caching to simplify the argument). Clearly somewhere in your code you have to explicitly handle tab closing and break the references to allow the GC to do its job. Why not free the r…
I mostly agree with your point on RAII. But I don't think OP was advocating RAII. The typical argument for GC is that it is less error-prone than even RAII. And I agree with that point. It's a trade-off on which you have to decide on. I think the tiny perf penalty is often worth it. You can still retain stale data under a GC, but real leaks (unreachable allocated memory) are precluded — which is usually considered (n…
This is why weak references were invented.