A question about the GC
    Kirk McDonald 
    kirklin.mcdonald at gmail.com
       
    Sun Dec 23 20:27:59 PST 2007
    
    
  
Jarrod wrote:
> Hey all,
> 
> I have a C library that takes the address to a class and stores it, 
> associating the address of the class with a cluster of data. That way, if 
> I try to create a second class tied to the same data, it merely passes 
> back the address of the first class. Also, if the data is destroyed, it 
> explicitly calls the class destructor for me.
> 
> This is all well and good, but my concern is that the garbage collector 
> may reallocate my class if it is a 'copying' gc (I'm not really sure what 
> it really is, I can't see it mentioned anywhere). If my class is moved, 
> what happens to the pointers in my C code? Will they be updated too? I 
> doubt it.
> Is this a cause for concern or is D's GC of the non-moving variety? If it 
> does indeed move I guess I'll have to override new/delete.
> 
> Thanks,
It is a non-moving GC. Also, the D GC won't see any pointers held by the 
C library, so be sure that you keep references to your GC-controlled 
classes in your D code, where the GC can see them.
-- 
Kirk McDonald
http://kirkmcdonald.blogspot.com
Pyd: Connecting D and Python
http://pyd.dsource.org
    
    
More information about the Digitalmars-d-learn
mailing list