Is the leak in not calling untie, or in looking at $^V? My assumption is that it was from not calling untie. Which is why I'm suggesting doing that unconditionally before running the original code.
If looking at $^V is a memory leak, that would be really bad. On Tue, Dec 13, 2016 at 2:16 PM, Duane Bronson <[email protected]> wrote: > By the time we update to a new version of Perl, I will not likely remember > this kludge, so I'm hoping to future-proof it. > > Calling $orig_destroy will still run "unless ($^V ...)" and thus leak > memory, so I can't future-proof that way. Now, if I can add a destructor > to the class 'version', maybe I can future proof that way, although I've > tried that and failed. I think it might be a bug in the comparison logic > (overloading?), but I can't find that code. Is that built into perl? > > Duane > > On Dec 13, 2016, at 4:30 PM, Ben Tilly <[email protected]> wrote: > > Module upgrades may not be likely, but I was responding to the first > question which was: > > "...I suspect there are better methods that won't break with a future > version of IO::All." > > On Tue, Dec 13, 2016 at 1:26 PM, Conor Walsh <[email protected]> wrote: > >> On Tue, Dec 13, 2016 at 4:20 PM, Ben Tilly <[email protected]> wrote: >> > The reason to call the original DESTROY is so that if a future version >> of >> > IO::All adds logic to the DESTROY, you will still run that new code. >> >> This is an excellent point, but it does not sound like surprise module >> upgrades are a likely problem in Duane's world. >> > > > > On Dec 13, 2016, at 4:20 PM, Ben Tilly <[email protected]> wrote: > > The reason to call the original DESTROY is so that if a future version of > IO::All adds logic to the DESTROY, you will still run that new code. While > still running the code that you know you need to run. > > In fact I would suggest the following instead: > > use IO::All; > { > no warnings 'redefine'; > my $orig_destroy = *IO::All::DESTROY{CODE}; > sub IO::All::DESTROY { > my $self = shift; > no warnings; > untie *$self if tied *$self; > $orig_destroy->($self, @_) if $orig_destroy; > } > } > > Now the custom code that you run is limited to what you are afraid that > their DESTROY gets wrong. > > (Note that my original version had a bug. I said IO::ALL::DESTROY when it > needed to be IO::All::DESTROY.) > > > > > > *Duane Bronson* > [email protected] > http://www.nerdlogic.com/ > 5 Goden St. > Belmont, MA 02478 > 617.515.2909 > > > > > _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

