> Decisions of GC models rapidly become religious arguments.

The most important argument is: Does a particular 
GC model meet the Perl 6 language requirements?

Reference counting fulfills the language requirement 
for deterministic destructor calls. (Those 
destructors might be freeing non-memory resources 
such as Oracle database connections and file 
handles.) However, it forces language users to 
beware of circular references. In the case of circular 
references, destructors are not called and memory not
freed until the program ends.

Mark and sweep GC solves the circular reference
problem. Also, it can sometimes provide faster 
execution. However, it loses deterministic destructor
calls. Expensive or rare resources are not freed as 
soon as possible with mark and sweep schemes.

Perhaps a hybrid approach would solve all the
language needs. Retain reference counting. When the
count drops to zero, call the destructor and mark 
the object. Free marked objects when sweep runs.
To reclaim circular references, the sweep task may
periodically scan the stack, globals, etc. The scan
would find circular references and set their counts 
to zero. Because circular references are rare, the 
scan need not occur every time a sweep is performed.
This example shows that you can offend all
"religious" camps and still capitalize on their 
disparate arguments.

The language requirements should drive the selection
of a GC model -- not fear or deference to a set of
idealistic opinions.

Reply via email to