[fpc-pascal] Interface delegation causes memory leak

Zamrony P. Juhara zamronypj at yahoo.com
Fri Aug 30 00:12:57 CEST 2019


   
   - 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20190829/86295d2f/attachment.html>


More information about the fpc-pascal mailing list