Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: NYAKNYAN [...] cpan.org
Cc:
AdminCc:

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



Subject: Circular reference in Net::DNS::Packet <-> Net::DNS::Header
Hi. Net::DNS::Packet holds reference to Net::DNS::Header line 212 (header method) > $self->{header} ||= new Net::DNS::Header($self); and passes self to it. Net::DNS::Header holds reference to parent Net::DNS::Packet object in "xbody", creating circular reference which result in memory leak. Simply adding weaken (from Scalar::Util) in Net::DNS::Header constructor Show quoted text
> weaken $self->{xbody};
works in my case.
From: rwfranks [...] acm.org
On Thu Aug 08 08:22:49 2013, NYAKNYAN wrote: Show quoted text
> Hi. > > Net::DNS::Packet holds reference to Net::DNS::Header > > line 212 (header method) > $self->{header} ||= new > Net::DNS::Header($self); > > and passes self to it. Net::DNS::Header holds reference to parent > Net::DNS::Packet object in "xbody", creating circular reference which > result in memory leak. > Simply adding weaken (from Scalar::Util) in Net::DNS::Header > constructor
> > weaken $self->{xbody};
> works in my case.
From: rwfranks [...] acm.org
The memory leak issue is covered by RT#81942 and RT#84601. Your suggestion to use a weak reference is excellent, but unfortunately does not work with old versions of Perl. The current distribution is intended to work on every platform and Perl revision from 5.6.1 upwards; although there are a couple of portability issues which still need to be fixed. The proposed solution involves moving internal state variables from Header to Packet so that only a single object reference is necessary to navigate between corresponding pairs of Packet and Header objects. This will appear in 0.73 as soon as testing is complete. Dick On Thu Aug 08 08:22:49 2013, NYAKNYAN wrote: [snip] Show quoted text
> Simply adding weaken (from Scalar::Util) in Net::DNS::Header > constructor
> > weaken $self->{xbody};
> works in my case.
Thanks for pointing out this simple and elegant solution. Like Dick said, the issue is addressed already in a different way. Closing ticket.