large objects and GC

Vladimir Panteleev thecybershadow at gmail.com
Fri May 16 14:54:49 PDT 2008


On Sat, 17 May 2008 00:32:26 +0300, Fawzi Mohamed <fmohamed at mac.com> wrote:

> The problem is that if the owner/object that do reference counting are managed by the gc they might stay uncollected for a quite long time because they are probably small, so one needs to really do everything manually, use scope,...

I don't understand your logic here. The GC does not prioritize objects based on their size. Smaller objects are much less likely to leak because of the proportionally smaller chance of a bogus pointer keeping it "referenced".

> One could to add a flag to the garbage collector. This flag would say to the gc to ignore inner pointer in a region when deciding if the region should be collected.
> To have internal pointers one should also keep a pointer to the base object.

This will be effectively the same as having a "wrapper" class for manually allocated memory. The class destructor, which will be called by the GC, should deallocate the external memory. The wrapper class should only have one field, and thus be very small and it will have the chance of leaking almost equivalent to the method you describe. I see no necessity for reference counting either, you just pass around the reference to the wrapper object.

> (but the pointers should be updated when the region is moved)

A moving garbage collector must also be an exact garbage collector.

-- 
Best regards,
 Vladimir                          mailto:thecybershadow at gmail.com



More information about the Digitalmars-d mailing list