GC And I Go Way Back
Sunday, January 01, 2006, at 08:22PM
By Eric Richardson
I've basically been working on that memory leak all day, which may or may not surprise you. I've probably learned a lot about garbage collection and Perl variable storage, but I haven't gotten all that far toward the practical objective of stopping the leak.
Making matters interesting is the fact that eThreads is built with circular structures galore. Perl's reference counting garbage collector really doesn't like that. I've made use of Scalar::Util::weaken where it made sense, and I think all the obvious situations are taken care of. Perhaps some non-obvious ones as well. Just don't ask about code like this:
if ($obj->{_}) {
my $a = $obj->{_};
my $sv = bless \$a, 'B::SV';
( $sv->REFCNT > 2 )
&& Scalar::Util::weaken($obj->{_});
}
Just a few minutes ago, though, I found that my Template objects aren't getting cleaned up until global destruction, which means they aren't ever falling out of scope. Now to figure out why...