On Tue, 7 Nov 2017, African Wild Dog wrote:
Hello,
Using ReadXMLFile function from XMLRead unit generates memory leaks when
trying to read a invalid XML content.
The "memory leak" is the exception object: you are not catching the exception.
Change your program to the below, and you'll see that it is not leaking
memory in the XML routines itself.
Michael.
---
program xml_leak_test;
uses
Classes,
DOM,
XMLRead;
Procedure doit;
var
XMLDocument: TXMLDocument;
InvalidStream: TStringStream;
const
INVALID_XML_CONTENT = '<<<INVALID XML>>>';
begin
XMLDocument := nil;
InvalidStream := TStringStream.Create(INVALID_XML_CONTENT);
try
ReadXMLFile(XMLDocument, InvalidStream);
finally
InvalidStream.Free;
XMLDocument.Free;
end;
end;
begin
SetHeapTraceOutput('heap.trc');
try
doit;
except
end;
end.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal