Bookstore

Recent

Author Topic: Why is this interface delegation causing memory leak?  (Read 1334 times)

PascalDragon

  • Hero Member
  • *****
  • Posts: 1088
  • Compiler Developer
Re: Why is this interface delegation causing memory leak?
« Reply #15 on: September 02, 2019, 10:14:20 am »
The problem with PascalDragon's solution is TDelegateTalker becomes tightly-coupled with TTalker class. To me, this is defeat the purpose of interface.
The main purpose of interface delegation is not to avoid tight coupling, but to reuse implementations.
That said it should be possible to design the classes in a way that interface injection is possible, however one needs to know exactly what one is doing regarding reference counting to avoid potential memory leaks.