Sign in Join

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

Mailing lists / fpc-pascal / 2019-08

Interface delegation causes memory leak

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

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

Zamrony P. Juhara
   - unit DelegateTalkerImpl;
   -  
   - interface
   -  
   - {$MODE OBJFPC}
   -  
   - uses
   -  
   -     TalkerIntf;
   -  
   - type
   -  
   -     TDelegateTalker = class(TInterfacedObject, ITalker)
   -     private
   -         fActualTalker : ITalker;
   -     public
   -         constructor create(const talker : ITalker);
   -         destructor destroy(); override;
   -  
   -         property talker : ITalker read fActualTalker implements ITalker;
   -     end;
   -  
   - implementation
   -  
   -     constructor TDelegateTalker.create(const talker : ITalker);
   -     begin
   -         fActualTalker := talker;
   -     end;
   -  
   -     destructor TDelegateTalker.destroy();
   -     begin
   -         fActualTalker := nil;
   -         inherited destroy();
   -     end;
   -  
   - end.

Above class, which employs interface delegation, cause memory leak. Detail how to reproduce can be read in https://forum.lazarus.freepascal.org/index.php/topic,46575.0.html

or
Why is this interface delegation causing memory leak?

|
|
|
| | |

|

|
|
| |
Why is this interface delegation causing memory leak?

Suppose I have following codes Unit TalkerIntf.pas unit TalkerIntf; interface {$MODE OBJFPC} type ITal... |

|

|

Is this a bug as mentioned by David Heffernan?
Regards,

Fano Frameworkhttps://fanoframework.github.io

Reply by email