[fpc-devel] Improving Ref Counting

Marco van de Voort marcov at stack.nl
Sun Feb 27 13:08:58 CET 2005


> > a valid/invalid reference without accessing memory that is invalid in the mean
> > time.
> 
> How does a GC do this? It would have the same problem?

A GC manages all memory, local variable allocation inclusive. IOW, the
way a GC does it, is not possible in a mixed environment.
 
> > Also note that the list of references must be a dynamically size structure,
> > incurring getmem and size-change overhead on a simple assignment.
> 
> yes a "single linked list" is a very efficient dynamically sized 
> structure and much cheaper than try..finally or using Tlist.

It's very expensive. getmem is quite expensive, and you need it for every
reference this way.

> > I doubt performance would improve, specially since the edge of this problem
> > (the worst 90%) can be taken off by simply disabling try...finally generation
> > in places where they are unlikely to happen.
> 
> Is there a real failsafe way of doing that?

Nothing is failsafe. However e.g. in RTL string routines exceptions
shouldn't occur unless memory is exhausted, in case it doesn't matter
much anyway.





More information about the fpc-devel mailing list