MIME-Version: | 1.0 |
X-Mailer: | MIME-tools 5.405 (Entity 5.404) |
Subject: | Memory leak when is used $elm->find |
Content-Type: | multipart/mixed; boundary="----------=_1019659799-25869-3" |
Content-Length: | 0 |
Content-Type: | text/plain |
Content-Disposition: | inline |
Content-Transfer-Encoding: | binary |
X-RT-Original-Encoding: | iso-8859-1 |
Content-Length: | 571 |
When running the following code :
1 # $msg holds XML message
2 while (1) {
3 my $parser = XML::LibXML->new();
4
5 my $doc = $parser->parse_string($msg);
6 my $elm = $doc->getDocumentElement;
7 my $node = $elm->find('/xpath/that/finds/a/node');
8 my $text = $node->to_literal->value;
9 undef $doc;
10 undef $parser;
11 }
the program leaks memory. When line 7 is commented out (and 8) it
does not leak. When line 9 is commented out the memory leak
becomes a memory torrent, especially if $msg is big ( say 300k )
Content-Type: | text/plain |
Content-Disposition: | inline |
Content-Transfer-Encoding: | binary |
X-RT-Original-Encoding: | iso-8859-1 |
Content-Length: | 0 |