large objects and GC

Fawzi Mohamed fmohamed at mac.com
Fri May 16 14:32:26 PDT 2008


There was recently a discussion on large array and GC.

The main conclusion was that the fact that the garbage collector is not 
exact large arrays don't get collected. On tango this seems less 
problematic, but can still be an issue.

I am writing something that needs large arrays, and one obvious 
solution is to manually allocate the memory.
This works, but then one has to use some kind of memory management, for 
example either having just 1 owner, or using reference counting (with 
synchronization or atomic operations).
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,...
Obviously this is efficient and one should do it with large objects, 
but it would be nice if the thing could transition more gracefully to 
an automatic managed model.

Large object when allocated should get a region for themselves when 
allocated with the gc, so there could be another approach.
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 (but the pointers should be updated when the 
region is moved).

To have internal pointers one should also keep a pointer to the base object.
Basically one has automatic reference counting, where the references 
are pointers to the base object.
The advantage is that it is automatic, and that memory can be relocated.

If other think it it is a good idea I am willing to invest some time to 
explore it.

Fawzi




More information about the Digitalmars-d mailing list