[Lazarus] heaptrc - Is it even worth using?

Lee Jenkins lee at datatrakpos.com
Mon Oct 5 18:47:05 CEST 2009


Sergei Gorelkin wrote:
> Lee Jenkins wrote:
> 
>>
>> Definitely related to TXMLDocument.  Apparently, it is either a 
>> complete mess and fraught with memory leaks or am misunderstanding how 
>> to use it.  Although, its not the first XML API I've used.
>>
>> Once again, its back to Delphi I go :-(
>>
> Your trouble looks like issue 13605, which was fixed in the meantime.
> One way out is to update the FPC; if that's not possible, you might want 
> to change your code to look like this:
> 
> 
>   lRegItem := lRegs.FirstChild;
>   while Assigned(lRegItem) do
>     begin
>       if lRegItem.nodeType = ELEMENT_NODE then
>       begin
> {1}     lClassName := TDOMElement(lRegItem).GetAttribute('classname');
>         lDataTable := ...
>         lObjType := ...
>         lObjReg := gMapppings.RegisterMapping(lClassName, lDataTable, 
> lObjType);
>         with lObjReg do
>         begin
>           lNode := lRegItem.FirstChild;
>           while Assigned(lNode) do
>             begin
>               if lNode.nodeType = ELEMENT_NODE tnen
>               begin
>                 lpK := ...
>                 lPropName := ...
>                 lColName := ...
>                 lValType := ...
> 
>               //dtInteger, dtFloat, dtString, dtDateTime, dtBookean, 
> dtBinary)
>                 lObjReg.RegisterProperty(lPropName, lColName,
>                   TFlexDataType(Integer(gDataTypeStrToInt(lValType))), 
> lPK);
>               end;  // if lNode.nodeType
>               lNode := lNode.NextSibling;
>             end;  // while
>         end;  // with lObjReg
>      end;     // if lRegItem.nodeType
>      lRegItem := lRegItem.nextSibling;
>    end;       // while
> 
> Note that the change marked as {1} is not related to the problem, it 
> just shows how to get the attribute value in a more short way.
> 

I'll give it a try.  I'm updating my snapshot installation of Lazarus on 
Windows, though I'm not sure if the fix will be included.

Also, Node.NextSibling doesn't seem to work either as it seems to return the 
exact same node and results in an endless loop.

I'll try again with the latest snapshot available.  Pulling down and building 
from source is a bit of a pain on Windows.

I'm just a little surprised that there is/was such a problem with XML 
implementation in Lazarus as XML is fairly important these days. :-)

--
Warm Regards,

Lee




More information about the Lazarus mailing list