[fpc-devel] Boehm garbage collector for freepascal
Thaddy
thaddy at thaddy.com
Mon Nov 15 15:14:36 CET 2010
On 15-11-2010 14:50, Marco van de Voort wrote:
>
> Oh. Am I supposed to do that? :-)
>
Yes, please :-) , but others are welcome...
> (I just collect info about this subject because it is a recurring white
> elephant. Regularly there is talk about it, but nobody has seen a working
> implementation, and nobody knows if proof of implementation on C++
> really does translate to Delphi. (like the finalization bit below)
>
This is such a working example, including the finalization part. Note:
this requires objects/classes that need finalization to be registered.
> I was thinking that one would install a heapmanager with a freemem
> that does
> nothing. Unfortunately the prototype can't zero the pointer (like
> freeandnil does)
>
> All allocations are eventually getmem/freemem, so redirecting getmem to the
> gc's prefered memory allocation and making freemem a no-op would be enough I
> guess.
>
No, it isn't, well isn't always.
>> Tobject descendants may require finalization before the garbage
>> collector cleans them, hence my question.
> Hmm, yes. That means indeed the GC must be able to call a callback on a
> block that must be freed, and some call to finalize must be made there. But
> will you have enough context to do so?
>
> Or will we simply not finalize and let the GC collect ansistrings and the
> like too? I always assumed that.
> ______
I took great pains in making sure ansistrings are released correctly
(see example). This took some effort and reading
and still I am not sure I am correct. The memory allocation abstraction
for Freepascal differs from Delphi.
And there is enough context because the finalizer calls the destructor,
not free. Hence my question about adapting Tobject.
I might be *very* wrong, though!
More information about the fpc-devel
mailing list