Faster Virtual Method Dispatch
xs0
xs0 at xs0.com
Wed Apr 26 09:28:04 PDT 2006
> Not true. A hierachical memory management system is great! It sure
> beats reference counting, manual memory management, and conservative GC.
>
> What you do is allocate some memory, but also provide a "parent" memory
> pointer to relate the new memory to. When all is said and done you have
> a nice tree of related memory pointers (hopefully with just one root,
> provided you designed correctly).
>
> To free some memory, simply walk all the branches of that node, freeing
> their memory, then free the original memory. You can even get
> predictable destructors for objects this way.
>
> I'm currently developing a project in C which uses this method. I have
> it allocating lots of small blocks of memory to perform a job. The
> total comes to 32KB. When the program is finished I do one "free" call
> to the root structure and I get back ALL of my memory. Not a single
> byte is leaked.
But how can you tell _when_ to delete the root? AFAIK, the main benefit
of GC is not that you don't have to manually free the memory, but that
you don't have to know when it is safe to do so. I don't see how
organizing memory blocks into a tree solves that...
xs0
More information about the Digitalmars-d
mailing list