I'm using Delphi to create an XML document from data in a relational database. It tests fine with small datasets, but when I try to expand the size of the data set to production levels it eventually bombs out with an EOutOfMemory exception during node creation.
I'm using a TXMLDocument dropped on a form (MSXML as the Vendor), and my code generally looks like this:
DS := GetDS(Conn, 'SELECT Fields. . . FROM Table WHERE InsuredID = ' +IntToStr(AInsuredID));
try
while not DS.Eof do
with ANode.AddChild('LE') do
begin
AddChild('LEProvider').Text := DS.FieldByName('LEProvider').AsString;
// Need to handle "other" here
AddChild('Date').Text := DateToXMLDate(DS.FieldByName('LEDate').AsDateTime);
AddChild('Pct50').Text := DS.FieldByName('50Percent').AsString;
AddChild('Pct80').Text := DS.FieldByName('80Percent').AsString;
AddChild('Actuarial').Text := DS.FieldByName('CompleteActuarial').AsString;
AddChild('Multiplier').Text := DS.FieldByName('MortalityMultiplier').AsString;
DS.Next;
end;
finally
DS.Free;
end;
with this section, as well as numerous other similarly constructed sections applying to different database tables, executed many times. In this example ANode is an IXMLNode passed in to the function for use as a container.
I do not expect the resulting XML file on disk to be more than 10 megabytes. I assume that somehow I'm leaking memory in my creation and disposal of XMLNodes, but I'm not familiar enough with Interfaces to know how to track down my problem.