I'm curious as to whether people are using weak interface references in anger?

I'm curious as to whether people are using weak interface references in anger? (http://blog.marcocantu.com/blog/2016-april-weak-unsafe-interface-references.html) In a nutshell - these were a new language feature for the desktop compilers a couple of releases ago, along with 'unsafe' interface references. The latter (no _AddRef and _Release calls, but you deal with any dangling pointers manually) work like they say on the tin, however weak references (which get automatically nil'ed when the referenced object is destroyed) I'm finding a bit problematic:

- The don't work with the Supports function, which remains a key way to actually get an interface reference in the first place. For sure the workaround is easy enough (use Supports against a local field without the [weak] annotation first), but it does involve a further interface type pitfall for the unwary.
- Weak interface references break external memory managers. Who really manages to get by without standalone FastMM in debug mode...? (https://github.com/pleriche/FastMM4/issues/18)

The first issue makes me pause, but the second is a real killer for me - does anyone have a proper workaround...?

Comments