Transitioning to a type aware Garbage Collector
Chris Miller
chris at dprogramming.com
Tue Jan 23 10:04:30 PST 2007
On Mon, 22 Jan 2007 18:38:05 -0500, Walter Bright
<newshound at digitalmars.com> wrote:
> Andrei Alexandrescu (See Website For Email) wrote:
>> Sounds great. Any possibility to type memory post factum (useful in
>> e.g. implementing allocators)? That is, allocate memory as void[] and
>> then mark it to be of type Foo.
>
> Looks like that will have to be implemented.
What about allocating a bigger chunk and dividing it up as a few types?
I have an idea how to make this work, all memory allocated could have
another chunk associated with it that denotes what are pointers. It would
only need to use one bit per pointer size.
e.g.
struct Foo
{
int x;
int* y;
}
would only need 1 byte to track pointer info: 01000000
with a few bits either wasted or used for the allocation at the next
address.
void[] would probably have all bits 1, and any non-pointer, like byte[],
would be all bits 0.
This lets you very easily reuse memory. Memory reuse is important for some
things, such as with realtime programming or general use of memory pools.
- Chris
More information about the Digitalmars-d-announce
mailing list