Skip Menu |

This queue is for tickets about the Net-DNS CPAN distribution.

Report information
The Basics
Id: 81942
Status: resolved
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: bwijnen [...] ripe.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Memory Leak in Net::DNS::Packet
Date: Thu, 13 Dec 2012 14:50:25 +0100
To: bug-Net-DNS [...] rt.cpan.org
From: Bert Wijnen <bwijnen [...] ripe.net>
When using Net::DNS::Packet, like this: while (input) { # I am processing some 3M DNS reponse packets. # but even with 20K you can see the problem clearly # We do have NSID data in the EDNS section. # but I believe it happens on all response packets ... if ($decode_packet) { my $packet; $packet = Net::DNS::Packet->new(\$data); $packet->print; # following 2 lines can be used to see that xbody point to $packet. #print "$packet->{header}->{xbody}\n"; #print "$packet\n"; } } I am detecting a memory leak. Turns out that packet->{header}=>{xbody} contains a pointer to the packter itself. And so when $packet goes out of scope, the reference count is still 1. I have bypassed it by doing if ($decode_packet) { my $packet; $packet = Net::DNS::Packet->new(\$data); $packet->print; undef $packet->{header}->{xbody}; } And now my memory leaks are gone. I guess Packet should have a DESTROY method that does the undef fo xbody, so that the packet can actually be garbage collected when it goes out of scope. --- version of Perl (output of 'perl -V' is best) This is perl 5, version 12, subversion 3 (v5.12.3) built for darwin-multi-2level Copyright 1987-2010, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page. --- version of Net::DNS I tried versions 0.69 and 0.70 --- operating system type and version MAC OS X 10.6.8 --- version of nameserver (if known) response packets for NSID from kroot --- exact text of error message or description of problem --- the shortest possible program that exhibits the problem see above, but probably need to process a response packet that has EDNS data. --- the specific queries you're making, if the data is available to Internet nameservers I can send a batch of packets if you want, but the bug seems pretty clear in my mind Bert Wijnen
From: rwfranks [...] acm.org
Adding a DESTROY function which removes the indirect self-reference. This should appear in 0.71
Subject: Re: [rt.cpan.org #81942] Memory Leak in Net::DNS::Packet
Date: Fri, 14 Dec 2012 09:02:40 +0100
To: bug-Net-DNS [...] rt.cpan.org, Bert Wijnen <bwijnen [...] ripe.net>
From: Bert Wijnen <bwijnen [...] ripe.net>
On 12/14/12 1:06 AM, Dick Franks via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=81942 > > > Adding a DESTROY function which removes the indirect self-reference. > > This should appear in 0.71 >
Great and thanks, Bert