[Lazarus] XML and memory loss

Bart bartjunk64 at gmail.com
Thu Oct 9 10:59:41 CEST 2008


>
> The memory leak is caused by using the ChildNodes property. Each time
> you use it, a new TDOMNodeList object is created, which must be
> eventually destroyed by calling Free. The FCL DOM implementation does
> not offer automatic memory management here, unlike other implementations.


Then how can I free those TDOMNodeList objects? I.o.w. how can I get access
to them?

Some time ago I updated the English page of Wiki tutorial to reflect
> this fact.


Yep, just re-read the article and saw the note...

In your case, ChildNodes.Item[0] can be replaced by FirstChild, which
> will return exactly the same node.


I tried that, and it wordk like a charm.
However can I use that approach if I want to create more complex XML files?

Eventually I want someting like this:
<?xml version="1.0"?>
<root>
  <version>foo bar version 0.0.1</version>
  <children>
    <child id="0001">
      <foo>Bart</foo>
      <bar>me, myself and I</bar>
    </child>
    <child id="0002">
      <foo>Bob</foo>
      <bar>blah</bar>
    </child>
 <children/>
</root>

Bart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20081009/22ffed29/attachment-0007.html>


More information about the Lazarus mailing list