3 ms·
Yes I think you would use a ref counted resource in that case. For your tangled mess of database connections I can't imagine ref counting not being adequate in
by rian 13y ago
Yes I think you would use a ref counted resource in that case. For your tangled mess of database connections I can't imagine ref counting not being adequate in those scenarios as well.
- danbruc 13y agoAnd now we are back at garbage collection - the two main options are reference counting GCs and collecting GCs. I know it for the .NET GC, they tried a reference counting GC and it performed worse than a collecting GC and not to forget the trouble with cycles when implementing a reference counting GC. And reference counting also renders the point of determinism moot - now you never know if releasing a reference while trigger freeing a resource. You could of course delay offload it to a separate thread, but this makes you lose any guarantee about the time when the resource is actually freed, too.
- rian 13y agoAh, I don't think ref counting is generally considered GC. It's more like RAII and used in C++ elsewhere via shared_ptr.
- danbruc 13y agoIt is a mechanism to figure out if a resource is no longer in use and can be released - that sounds like the very definition of garbage collection.
- letzjuc 13y ago> And reference counting also renders the point of determinism moot - now you never know if releasing a reference while trigger freeing a resource. You know that releasing the last reference will. That is why the important concept is single ownership of resources and not reference counting by itself.
- danbruc 13y agoBut you don't know which reference is the last until you actually get there - that is why you used reference counting in the first place, because you were unable to statically determine which reference will be the last one. So every time you abandon a reference it might be the last one and you might have to spend extra cycles to free the resource. This is no more deterministic than a garbage collector.
- letzjuc 13y agoIn a non-deterministic garbage collector memory _might not_ be released when the last reference goes out of scope (and this is often the case).