[fpc-pascal] Mutual Reference Interfaces and Memory Leaks

African Wild Dog paintedlycaon at gmail.com
Mon Jun 26 17:39:16 CEST 2017


Hello,

What is the recommended way to avoid memory leaks in mutual interface
references?

>From delphi 10.1 Berlin it is possible to use [unsafe] e [weak] attributes.
http://blog.marcocantu.com/blog/2016-april-weak-unsafe-interface-references.html
.

Is there a workaround in Free Pascal 3?

Regards

==== CODE ====

type
  IMyInterfaceA = interface
     procedure Foo;
  end;

  IMyInterfaceB = interface
    procedure Bar;
  end;

  TMyInterfaceA = class(TInterfacedObject, IMyInterfaceA)
  private
     var FMyInterfaceB: IMyInterfaceB;
      ....
  end;


  TMyInterfaceB = class(TInterfacedObject, IMyInterfaceB)
  private
     var FMyInterfaceA: IMyInterfaceA;
      ....
  end;

   .........

=================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170626/3d0022a8/attachment.html>


More information about the fpc-pascal mailing list