On 24 May 2013 15:21, deadalnix <deadal...@gmail.com> wrote: > On Thursday, 23 May 2013 at 23:42:22 UTC, Manu wrote: > >> I've always steered away from things like this because it creates a >> double-indirection. >> I have thought of making a similar RefCounted template, but where the >> refCount is stored in a hash table, and the pointer is used to index the >> table. >> This means the refCount doesn't pollute the class/structure being >> ref-counted, or avoids a double-indirection on general access. >> It will be slightly slower to inc/decrement, but that's a controlled >> operation. >> I would use a system like this for probably 80% of resources. >> >> > Reference counting also tend to create die in mass effect (objects tends > to die in cluster) and freeze program for a while. I'm not sure it is that > better (better than current D's GC for sure, but I'm not sure it is better > than a good GC). It probably depends on the usage pattern. >
In my experience that's fine. In realtime code, you tend not to allocate/deallocate at runtime. Unless it's some short lived temp's, which tend not to cluster how you describe... When you eventually do free some big resources, causing a cluster free, you will have probably done it at an appropriate time where you intend such a thing to happen.