Memory leak in TXMLDocument ChildNodes.Count function
Original Reporter info from Mantis: and3md @and3md
-
Reporter name: Andrzej Kilijanski
Original Reporter info from Mantis: and3md @and3md
- Reporter name: Andrzej Kilijanski
Description:
When I try count DocumentElement.ChildNodes heaptrc report unfreed memory.
Code:
uses XMLRead, DOM;
var
Doc: TXMLDocument;
begin
ReadXMLFile(Doc, 't.xml');
Doc.DocumentElement.ChildNodes.Count; // when commented everything works fine
Doc.Free;
end.
Compile with options:
H:\testypascal\testxml2>C:\lazarus\fpc\2.2.5\bin\i386-win32\fpc -Mobjfpc -gh xml_test.pas
Free Pascal Compiler version 2.2.5 [2009/04/28] for i386
Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Win32 for i386
Compiling xml_test.pas
Linking xml_test.exe
8 lines compiled, 0.2 sec , 176832 bytes code, 38776 bytes data
xml_test.exe launch returns:
Heap dump by heaptrc unit
86 memory blocks allocated : 11518/11792
83 memory blocks freed : 11466/11736
3 unfreed memory blocks : 52
True heap size : 458752 (96 used in System startup)
True free heap : 458400
Should be : 458432
Call trace for block $001145D8 size 16
$004090EB
$0041D0C7
$0040BB90
$00414972
$004014E1
$0040BB90
Call trace for block $00114588 size 16
$00406FF2
$00415D8A
$00414F81
$0040BB90
Call trace for block $0011C3B0 size 20
$00406FF2
$00414F81
$0040BB90
$0040BB90
t.xml file has only:
&LtPos;?xml version="1.0" encoding="UTF-8"?>
&LtPos;A1>
<A2>
</A2>
&LtPos;/A1>
When you remove Doc.DocumentElement.ChildNodes.Count line everything is ok.
Mantis conversion info:
- Mantis ID: 13605
- OS: Windows
- OS Build: Vista 32bit
- Build: 2009/04/28
- Platform: i386
- Version: 2.2.5
- Fixed in version: 2.4.0
- Fixed in revision: 13180 (#035fe43b)