<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Verdana; font-size: 12pt; color: #000000'>Hi Yves,<br><br>Thanks for your remark. I will modify the code.<br><br>Regards,<br>--<br>Pierre Delore<br><br>http://datalinkwristapps.free.fr<br>http://dpsite.free.fr<br><br>----- esby@free.Fr a écrit :
<br>> Besides what you corrected, the various 'exit' statement in your code<br>> will leave an xdoc unfreed.<br>> <br>> Pierre Delore wrote:<br>> > Hi,<br>> ><br>> > I'm finishing to develop an application. Everything works fine.<br>> Yesterday I made some tests and I noticed that I have a huge memory leak<br>> when I try to load new data.<br>> ><br>> > I load 6000 lines of data that I transfer in TFPObjectList. I first<br>> thought that the problem came from the list. I removed the list code and<br>> the problem doesn't disappear. So, for me, the problem come from the XML<br>> reading procedure. I try to search in the wiki and I didn't found thing<br>> that help me. I sure that the method I use to read the XML is not right<br>> one.<br>> ><br>> > Somebody can help me to correct my code?<br>> ><br>> ><br>> > The method without TFPObjectList code is below. Before reading the file<br>> the program use 16Mo of memory. After the execution of the 'LoadCGX'<br>> procedure the program use 204Mo :( .<br>> ><br>> ><br>> >><br>> -------------------------------------------------------------------------------------------------------------------<br>> > procedure TCGData.LoadCGX(s:String);<br>> > var<br>> > xdoc: TXMLDocument; // variable to document<br>> > RootNode,<br>> > node, node1, TrackpointNode : TDOMNode; // variable to nodes<br>> > i, j, err : Integer;<br>> > tmpCourseName : string;<br>> > tmpDescription : string;<br>> > tmps, tmps1 : string;<br>> > tmpTotalDistance,td : Double;<br>> > tmpVersion : String;<br>> > tmpTotalTimeSecond : integer;<br>> > ts : String;<br>> > Begin<br>> ><br>> > DateSeparator:='/';<br>> > ShortDateFormat:='d/m/y';<br>> ><br>> > //-- Open the XML file --<br>> > ReadXMLFile(xDoc, s);<br>> ><br>> ><br>> > //-- Search the <CourseGenerator> node --<br>> > RootNode := xDoc.FindNode('CourseGenerator');<br>> ><br>> > if RootNode=NIL then exit; //Not found exit<br>> ><br>> > For i:=0 to (RootNode.ChildNodes.Count - 1) do begin<br>> > Node:=RootNode.ChildNodes.Item[i];<br>> > tmps:=Node.NodeName;<br>> ><br>> > if tmps='Version' then begin<br>> > //-- <Version> node --<br>> > tmpVersion:= Node.TextContent;<br>> > //Todo: test!<br>> > end<br>> > else if tmps='TotalDistance' then begin<br>> > //-- <TotalDistance> node --<br>> > Val(Node.TextContent,tmpTotalDistance,err);<br>> > if err<>0 then exit;<br>> > end<br>> > else if tmps='TotalTimeSecond' then begin<br>> > //-- <TotalTimeSecond> node --<br>> > Val(Node.TextContent,tmpTotalTimeSecond,err);<br>> > if err<>0 then exit;<br>> > end<br>> > else if tmps='CourseName' then begin<br>> > //-- <CourseName> node --<br>> > tmpCourseName:= Node.TextContent;<br>> > end<br>> > else if tmps='Description' then begin<br>> > //-- <Description> node --<br>> > tmpDescription:= Node.TextContent;<br>> > end<br>> ><br>> > else if tmps='Trackpoint' then begin<br>> > //-- <Trackpoint> node --<br>> > TrackpointNode := Node;<br>> ><br>> > //-- Scan level "trackpoint" --<br>> > for j := 0 to (TrackpointNode.ChildNodes.Count - 1) do begin<br>> > Node1:=TrackpointNode.ChildNodes.Item[j];<br>> > tmps1:=Node1.NodeName;<br>> ><br>> > if tmps1 = 'LatitudeDegrees' then begin<br>> > //<LatitudeDegrees>123.456</LatitudeDegrees><br>> > val(Node1.TextContent,td,err);<br>> > if err<>0 then begin<br>> > td:=0;<br>> > //Error<br>> > end;<br>> > end<br>> > else if tmps1 = 'LongitudeDegrees' then begin<br>> > //<LongitudeDegrees>123.456</LongitudeDegrees><br>> > val(Node1.TextContent,td,err);<br>> > if err<>0 then begin<br>> > td:=0;<br>> > //Error<br>> > end;<br>> > end<br>> > else if tmps1 = 'AltitudeMeters' then begin<br>> > //<AltitudeMeters>123.456</AltitudeMeters><br>> > val(Node1.TextContent,td,err);<br>> > if err<>0 then begin<br>> > td:=0;<br>> > //Error<br>> > end;<br>> > end;<br>> > end; //For j<br>> > //-- Store data --<br>> > //List.Add(TmpData);<br>> > end;<br>> > end; //For i<br>> ><br>> ><br>> > RootNode.free;<br>> > xDoc.Free;<br>> ><br>> > End;<br>> >><br>> -----------------------------------------------------------------------------------------------------<br>> ><br>> ><br>> > Thanks for your help.<br>> ><br>> > Regards,<br>> ><br>> <br>> <br>> -- <br>> Yves Tennevin / esby <dot> free.fr<br>> <br>> http://esby.free.fr/contact.html<br>> <br>> <br>> --<br>> _______________________________________________<br>> Lazarus mailing list<br>> Lazarus@lists.lazarus.freepascal.org<br>> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus<br>> </div></body></html>