[fpc-devel] Interface scope incompatibility with Delphi

Marco van de Voort marcov at stack.nl
Fri Nov 12 12:01:42 CET 2010

In our previous episode, Thomas Schatzl said:

> What would be interesting would be how garbage-collected Delphis handle
> this, can anyone help? Other than that, there is imo nothing else to say
> than that Pascal/Delphi(*) does not have explicitly scoped lifetimes with
> automatic destructor call for classes/objects at the moment.

The .NET versions are simply different, and don't have refcounted
interfaces. You also need to implement a special interface to make sure a
destructor is called when it is destructed. IIRC the Delphi.NET hierachy
used this everywhere. (which was more compatible but slower)

Attempts to add Boehm collectors to native compilers ignore refcounts, since
they work with scanning for roots, and keeps counting references. I assume simply
removing the deallocation from the interfaces would be enough (since when
the last reference disappears, the GC will notice eventually). 

However while the Boehm GC route has been referenced many times for Delphi
and FPC ("if it can for C++, it can for Delphi"), I never saw a rapport of
somebody doing this with details (describing the setup etc).

An occasional claim has been made but afaik without any details (like the
size of the tested app)

If sb has info on this, please add it to


since the question comes up occasionally.

More information about the fpc-devel mailing list