Memory safety depends entirely on GC ?
via Digitalmars-d
digitalmars-d at puremagic.com
Mon Feb 23 07:35:50 PST 2015
On Monday, 23 February 2015 at 14:56:11 UTC, Marc Schütz wrote:
> violation of the principle of separation of concerns: a
> consumer shouldn't need to have information about the
> management strategy, it should work equally with
> `RefCounted!C`, `Unique!C` and bare (GC) `C`, as long as it
> doesn't take ownership of the resource.
Just be aware that by not making the refcount part of C you
either:
1. Need one more indirection.
2. Need a more complicated allocator to avoid alignment padding
when C has 32byte/64 byte alignment requirements.
3. Risk having the refcount landing on a different cacheline,
causing more cache misses.
If you do excessive refcounting (ARC) and care about performance
you actually need to let the implementor of C decide where the
RC_counter is embedded...
More information about the Digitalmars-d
mailing list