Subject: | Memory leak when is used $elm->find |
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 )