Knowledge of managed memory pointers

Manu via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 16 23:55:20 PDT 2014


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.

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?

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.

Obviously it needs to be super trivial to gather this information from the
pointer...
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.

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?

What about 'hacks' like an unlikely sentinel value at ptr[-1]?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140417/81306fbe/attachment.html>


More information about the Digitalmars-d mailing list