Re: destroy xml object

Thomas Krichel <[email protected]>
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>

  Michael Ludwig writes

> The first step would be to provide exact details instead of "through
> the roof"

  It's a memory leak. I have fixed the leak I think. I
  had a hash of XML::LibXML::Element object $multiple and
  a element $single_element, and I said

| my $to_add_element=$multiple->{$id} or next;
| $single_element->appendChild($to_add_element);

  This code leaks memory when you look through a bunch 
  of $single_elements. From my limited understanding,
  $single_element can not be destroyed because it references
  $to_add_element, which comes from the $multiple which is 
  constant throughout the loop. The solution is to say

| my $to_add_element=$multiple->{$id} or next;
| $to_add_element=$to_add_element->cloneNode(1);
| $single_element->appendChild($to_add_element);


  Cheers,

  Thomas Krichel                    http://openlib.org/home/krichel
                                http://authorclaim.org/profile/pkr1
                                               skype: thomaskrichel
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.