[fpc-devel] Improving Ref Counting
jamie-junk at blueyonder.co.uk
Sun Feb 27 13:22:09 CET 2005
Marco van de Voort wrote:
>>>a valid/invalid reference without accessing memory that is invalid in the mean
>>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.
Are you saying it would be a managed pointer then which is allocated on
the heap? (I had assumed the pointer would be on the stack and the
object in the heap)
>>>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.
Okay then use Tlist with preallocation of say half a dozen references -
that should be efficient for 99% of cases for an individual object's
>>>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.
What about all other non string exceptions that can occur between
creation and destruction of the ansistring?
Multithreaded environments too?
> fpc-devel maillist - fpc-devel at lists.freepascal.org
More information about the fpc-devel