Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2017-06

Mutual Reference Interfaces and Memory Leaks

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

African Wild Dog

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;
   .........

=================

Marcos Douglas B. Santos
to African Wild Dog
African Wild Dog wrote 11 lines
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?

Hi,

I wrote an article about it https://goo.gl/Lij4hu
But you need to translate from Portuguese to English.

Best regards,
Marcos Douglas

African Wild Dog
to Marcos Douglas B. Santos

2017-06-26 12:45 GMT-03:00 Marcos Douglas B. Santos :

Show quoted text 9 lines
Hi, I wrote an article about it https://goo.gl/Lij4hu But you need to translate from Portuguese to English. Best regards, Marcos Douglas

There are some parts of your article which are in English and you have added a link to another article, so it helped me a lot. Thanks for your reply.

I researched a bit more in google and found interesting the approach used in the Spring4D framework. I think it's compatible with Free Pascal.

For the compiler devs, will the compiler attributes features ([unsafe] and [weak]) be implemented in the near future?

Regards

Marcos Douglas B. Santos
to African Wild Dog
African Wild Dog wrote
There are some parts of your article which are in English and you have added a link to another article, so it helped me a lot. Thanks for your reply.

You are welcome.

Regards,
Marcos Douglas