<div dir="ltr"><div><div>Hello,<br><br></div>Using ReadXMLFile function from XMLRead unit generates memory leaks when trying to read a invalid XML content.</div><div><br></div>==== CODE ====<br><div><br></div><div>program xml_leak_test;<br><br>uses<br> heaptrc,<br> Classes,<br> DOM,<br> XMLRead;<br>var<br> XMLDocument: TXMLDocument;<br> InvalidStream: TStringStream;<br><br>const<br> INVALID_XML_CONTENT = '<<<INVALID XML>>>';<br><br>begin<br> SetHeapTraceOutput('heap.trc');<br><br> XMLDocument := nil;<br> InvalidStream := TStringStream.Create(INVALID_XML_CONTENT);<br> try<br>    ReadXMLFile(XMLDocument, InvalidStream);<br> finally<br>   InvalidStream.Free;<br>   XMLDocument.Free;<br> end;<br>end.<br></div><div><br></div><div>=======</div><div><br></div><div><br></div><div>HEAP trace content:</div><div><br></div><div>==== HEAP ===</div><div>Heap dump by heaptrc unit<br>105 memory blocks allocated : 18943/19216<br>101 memory blocks freed    : 18639/18912<br>4 unfreed memory blocks : 304<br>True heap size : 491520 (192 used in System startup)<br>True free heap : 490400<br>Should be : 490512<br>Call trace for block $00000000011EA650 size 40<br> $000000010000B7AB<br> $0000000100010A62<br> $0000000100010B6C<br> $000000007720812D<br> $00000000771F855F<br> $000000007722BCB8<br> $000007FEFD0BA06D<br> $BAADF00DBAADF00D<br>Call trace for block $0000000001200B80 size 128<br> $00000001000141E6<br> $000000010000B78B<br> $00000001000107D7<br> $0000000100010896<br> $0000000100037D56<br> $0000000100037C6E<br> $0000000100037A82<br> $BAADF00DBAADF00D<br>Call trace for block $0000000001208B70 size 88<br> $0000000100014347<br> $000000010000B78B<br> $0000000100005E15<br> $000000010000513A<br> $000000010002B9E8<br> $000000010002C000<br> $000000010002E4AF<br> $BAADF00DBAADF00D<br>Call trace for block $00000000011EA350 size 48<br> $000000010000B6F2<br> $00000001000090A7<br> $00000001000360A1<br> $0000000100037C42<br> $0000000100037A82<br> $000000010003786B<br> $00000001000389F8<br> $BAADF00DBAADF00D<br>==========<br></div></div>