Faster Virtual Method Dispatch

James Dunne james.jdunne at gmail.com
Wed Apr 26 19:05:23 PDT 2006


Walter Bright wrote:
> James Dunne wrote:
> 
>> Can you provide me a few legitimate examples of when you won't know 
>> what to free and when to free it?  I'm having a tough time coming up 
>> with examples on my own...
> 
> 
> One example that has plagued me in the past is having two distinct tree 
> data structures, and it becomes necessary for a node in one tree to 
> refer to data in the other.
> 
> Or when you have a third data structure, and you need to point to data 
> in one or the other or both of the first two trees.
> 
> A typical example of that is symbol tables inside the compiler. In the 
> DMD front end (which is garbage collected) the data has all kinds of 
> cross-connections in it.
> 
> I.e. the problem crops up when the data in memory just doesn't fit into 
> a strictly heirarcical format.

If you parent the memory you're creating in the tree data structures to 
a structure that is higher up the chain than both tree data structures, 
then the data doesn't get lost simply because you freed the data 
structure that held references to that memory.

-- 
Regards,
James Dunne



More information about the Digitalmars-d mailing list