<div dir="ltr">It occurs to me that a central issue regarding the memory management debate, and a major limiting factor with respect to options, is the fact that, currently, it's impossible to tell a raw pointer apart from a gc pointer.<div>
<br></div><div>Is this is a problem worth solving? And would it be as big an enabler to address some tricky problems as it seems to be at face value?</div><div><br></div><div>What are some options? Without turning to fat pointers or convoluted changes in the type system, are there any clever mechanisms that could be applied to distinguish managed from unmanaged pointers. If an API could be provided in druntime, it may be used by GC's, ARC, allocators, or systems that operate at the barrier between languages.</div>
<div><br></div><div>Obviously it needs to be super trivial to gather this information from the pointer...</div><div>On embedded systems with fixed/limited memory it's easy, just make the gc allocate pages in course physically aligned blocks and check a bit indexed by a couple of bits in pointers whether that page is owned by the GC or not.</div>
<div><br></div><div>On large scale OS's with unknown quantity (perhaps lots) of memory, it's not so simple, but they have other advantages, like virtual memory managers. Can virtual pages be attributed with a bit of data somehow that's easy to look up?</div>
<div><br></div><div>What about 'hacks' like an unlikely sentinel value at ptr[-1]?</div></div>