<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head><!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]--></head><body><div class="ydp4ea90c1ayahoo-style-wrap" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 13px;"><div dir="ltr" data-setdir="false"><div><ol style="color: rgb(0, 0, 0); font-family: monospace; white-space: pre-wrap;"><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"><span style="font-weight: bold;">unit</span> DelegateTalkerImpl<span style="color: rgb(0, 0, 102);">;</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"> </div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"><span style="font-weight: bold;">interface</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"> </div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"><span style="color: rgb(0, 128, 0); font-style: italic;">{$MODE OBJFPC}</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"> </div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"><span style="font-weight: bold;">uses</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"> </div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">    TalkerIntf<span style="color: rgb(0, 0, 102);">;</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"> </div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"><span style="font-weight: bold;">type</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"> </div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">    TDelegateTalker <span style="color: rgb(0, 0, 102);">=</span> class<span style="color: rgb(0, 153, 0);">(</span>TInterfacedObject<span style="color: rgb(0, 0, 102);">,</span> ITalker<span style="color: rgb(0, 153, 0);">)</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">    <span style="font-weight: bold;">private</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">        fActualTalker <span style="color: rgb(0, 0, 102);">:</span> ITalker<span style="color: rgb(0, 0, 102);">;</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">    <span style="font-weight: bold;">public</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">        <span style="font-weight: bold;">constructor</span> create<span style="color: rgb(0, 153, 0);">(</span><span style="font-weight: bold;">const</span> talker <span style="color: rgb(0, 0, 102);">:</span> ITalker<span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(0, 0, 102);">;</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">        <span style="font-weight: bold;">destructor</span> destroy<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(0, 0, 102);">;</span> <span style="font-weight: bold;">override</span><span style="color: rgb(0, 0, 102);">;</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"> </div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">        <span style="font-weight: bold;">property</span> talker <span style="color: rgb(0, 0, 102);">:</span> ITalker <span style="color: rgb(0, 0, 102);">read</span> fActualTalker implements ITalker<span style="color: rgb(0, 0, 102);">;</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">    <span style="font-weight: bold;">end</span><span style="color: rgb(0, 0, 102);">;</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"> </div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"><span style="font-weight: bold;">implementation</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"> </div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">    <span style="font-weight: bold;">constructor</span> TDelegateTalker<span style="color: rgb(0, 0, 102);">.</span><span style="color: rgb(0, 102, 0);">create</span><span style="color: rgb(0, 153, 0);">(</span><span style="font-weight: bold;">const</span> talker <span style="color: rgb(0, 0, 102);">:</span> ITalker<span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(0, 0, 102);">;</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">    <span style="font-weight: bold;">begin</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">        fActualTalker <span style="color: rgb(0, 0, 102);">:</span><span style="color: rgb(0, 0, 102);">=</span> talker<span style="color: rgb(0, 0, 102);">;</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">    <span style="font-weight: bold;">end</span><span style="color: rgb(0, 0, 102);">;</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"> </div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">    <span style="font-weight: bold;">destructor</span> TDelegateTalker<span style="color: rgb(0, 0, 102);">.</span><span style="color: rgb(0, 102, 0);">destroy</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(0, 0, 102);">;</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">    <span style="font-weight: bold;">begin</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">        fActualTalker <span style="color: rgb(0, 0, 102);">:</span><span style="color: rgb(0, 0, 102);">=</span> <span style="font-weight: bold;">nil</span><span style="color: rgb(0, 0, 102);">;</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">        <span style="font-weight: bold;">inherited</span> destroy<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(0, 0, 102);">;</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;">    <span style="font-weight: bold;">end</span><span style="color: rgb(0, 0, 102);">;</span></div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"> </div></li><li style="white-space: nowrap; padding: 0px 5px; line-height: 16px; border-left: 1px solid rgb(153, 153, 153);"><div style="font-stretch: normal; font-size: 1em; line-height: 1.2em; margin: 0px; padding: 0px; background: none; vertical-align: top;"><span style="font-weight: bold;">end</span><span style="color: rgb(0, 0, 102);">.</span></div></li></ol></div>Above class, which employs interface delegation, cause memory leak. Detail how to reproduce can be read in</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false"><span><a href="https://forum.lazarus.freepascal.org/index.php/topic,46575.0.html" rel="nofollow" target="_blank">https://forum.lazarus.freepascal.org/index.php/topic,46575.0.html</a></span><br></div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">or</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false"><span><a href="https://stackoverflow.com/questions/57708303/why-is-this-interface-delegation-causing-memory-leak" rel="nofollow" target="_blank" class="enhancr_card_7492589796">Why is this interface delegation causing memory leak?</a></span><div><br></div><div id="ydpce483bb8enhancr_card_7492589796" class="ydpce483bb8yahoo-link-enhancr-card ydpce483bb8ymail-preserve-class ydpce483bb8ymail-preserve-style" style="max-width:400px;font-family:Helvetica Neue, Segoe UI, Helvetica, Arial, sans-serif" data-url="https://stackoverflow.com/questions/57708303/why-is-this-interface-delegation-causing-memory-leak" data-type="YENHANCER" data-size="MEDIUM" contenteditable="false"><a href="https://stackoverflow.com/questions/57708303/why-is-this-interface-delegation-causing-memory-leak" style="text-decoration:none !important;color:#000 !important" class="ydpce483bb8yahoo-enhancr-cardlink" rel="nofollow" target="_blank"><table border="0" class="ydpce483bb8card-wrapper ydpce483bb8yahoo-ignore-table" cellpadding="0" cellspacing="0" style="max-width:400px"><tbody><tr><td width="400"><table border="0" class="ydpce483bb8card ydpce483bb8yahoo-ignore-table" cellpadding="0" cellspacing="0" width="100%" style="max-width:400px;border-width:1px;border-style:solid;border-color:rgb(224, 228, 233);border-radius:2px"><tbody><tr><td class="ydpce483bb8card-primary-image-cell" background="https://s.yimg.com/lo/api/res/1.2/1wUG32ibNb9ItOe48vjFFw--~A/Zmk9ZmlsbDt3PTQwMDtoPTIwMDthcHBpZD1pZXh0cmFjdA--/https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon@2.png?v=73d79a89bded.cf.jpg" bgcolor="#000000" valign="top" height="175" style="background-color: rgb(0, 0, 0); background-size: cover; position: relative; border-radius: 2px 2px 0px 0px; min-height: 175px;"><!--[if gte mso 9]><v:rect fill="true" stroke="false" style="width:396px;height:175px;position:absolute;top:0;left:0;"><v:fill type="frame" color="#000000" src="https://s.yimg.com/lo/api/res/1.2/1wUG32ibNb9ItOe48vjFFw--~A/Zmk9ZmlsbDt3PTQwMDtoPTIwMDthcHBpZD1pZXh0cmFjdA--/https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon@2.png?v=73d79a89bded.cf.jpg"/></v:rect><![endif]--><table border="0" class="ydpce483bb8card-overlay-container-table ydpce483bb8yahoo-ignore-table" cellpadding="0" cellspacing="0" style="width:100%"><tbody><tr><td class="ydpce483bb8card-overlay-cell" background="https://s.yimg.com/cv/ae/nq/storm/assets/enhancrV21/1/enhancr_gradient-400x175.png" bgcolor="transparent" valign="top" style="background-color: transparent; border-radius: 2px 2px 0px 0px; min-height: 175px;"><!--[if gte mso 9]><v:rect fill="true" stroke="false" style="width:396px;height:175px;position:absolute;top:-18px;left:0;"><v:fill type="pattern" color="#000000" src="https://s.yimg.com/cv/ae/nq/storm/assets/enhancrV21/1/enhancr_gradient-400x175.png"/><v:textbox inset="0,0,20px,0"><![endif]--><table border="0" class="ydpce483bb8yahoo-ignore-table" height="175" style="width: 100%; min-height: 175px;"><tbody><tr><td class="ydpce483bb8card-richInfo2" style="text-align:left;padding:15px 0 0 15px;vertical-align:top"></td><td class="ydpce483bb8card-actions" style="text-align:right;padding:15px 15px 0 0;vertical-align:top"><div class="ydpce483bb8card-share-container"></div></td></tr></tbody></table><!--[if gte mso 9]></v:textbox></v:rect><![endif]--></td></tr></tbody></table></td></tr><tr><td><table border="0" align="center" class="ydpce483bb8card-info ydpce483bb8yahoo-ignore-table" cellpadding="0" cellspacing="0" style="background:#fff;position:relative;z-index:2;width:100%;max-width:400px;border-radius:0 0 2px 2px;border-top:1px solid rgb(224, 228, 233)"><tbody><tr><td style="background-color:#ffffff;padding:16px 0 16px 12px;vertical-align:top;border-radius:0 0 0 2px"></td><td style="vertical-align:middle;padding:12px 24px 16px 12px;width:99%;font-family:Helvetica Neue, Segoe UI, Helvetica, Arial, sans-serif;border-radius:0 0 2px 0"><h2 class="ydpce483bb8card-title" style="font-size: 14px; line-height: 19px; margin: 0px 0px 6px; font-family: Helvetica Neue, Segoe UI, Helvetica, Arial, sans-serif; color: rgb(38, 40, 42);">Why is this interface delegation causing memory leak?</h2><p class="ydpce483bb8card-description" style="font-size: 12px; line-height: 16px; margin: 0px; color: rgb(151, 155, 167);">Suppose I have following codes  Unit TalkerIntf.pas  unit TalkerIntf;  interface  {$MODE OBJFPC}  type      ITal...</p></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></a></div><div><br></div><div dir="ltr" data-setdir="false">Is this a bug as mentioned by David Heffernan?</div><br></div><div dir="ltr" data-setdir="false">Regards,</div><div dir="ltr" data-setdir="false"><br></div><div><br></div><div class="ydp4ea90c1asignature" dir="ltr" data-setdir="false">Fano Framework</div><div class="ydp4ea90c1asignature" dir="ltr" data-setdir="false">https://fanoframework.github.io</div></div></body></html>