<font size="3"></font><font size="3"></font>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;">Hi,</p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;">if I run the code it writes "Unhandled exception". I tried to add another try..except block and it's OK.<span style="font-size: 10pt;"> </span></p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">program xml_leak_test;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">{$mode objfpc}</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">uses</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> heaptrc,</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> Classes,</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> DOM,</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> XMLRead;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">var</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> XMLDocument: TXMLDocument;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> InvalidStream: TStringStream;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">const</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> INVALID_XML_CONTENT = '<<<INVALID XML>>>';</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">begin</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> SetHeapTraceOutput('heap.trc');</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> XMLDocument := nil;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> InvalidStream := TStringStream.Create(INVALID_XML_CONTENT);</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> try</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> try</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> ReadXMLFile(XMLDocument, InvalidStream);</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> except</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> end;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> finally</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> InvalidStream.Free;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> XMLDocument.Free;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> end;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">end.</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">Note: when I tried your original code in Lazaur method, it didn't leak at all.</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">V.</p>
<p style="padding: 0 0 0 0; margin: 0 0 0 0;">______________________________________________________________<br />
> Od: African Wild Dog <paintedlycaon@gmail.com><br />
> Komu: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org><br />
> Datum: 07.11.2017 23:19<br />
> Předmět: [fpc-pascal] Memory Leak's in XMLRead unit<br />
></p>
<div dir="ltr">
<div>
<div>Hello,</div>
Using ReadXMLFile function from XMLRead unit generates memory leaks when trying to read a invalid XML content.</div>
<div>....</div>
</div>
<br />
<br />
----------<br />
<br />
_______________________________________________<br />
fpc-pascal maillist - fpc-pascal@lists.freepascal.org<br />
<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a>