The Time is: Dark
January 02, 2006 by Eric Richardson
On Friday night I got into LAX around 1:00am (ok, so really that's Saturday morning). The last two nights I've been up pretty late. And now it's 8:20pm and my body's not particularly tired but my head keeps trying to tell me it's really late. I guess that's what happens when the day never actually brightens up.
Going to sleep early isn't a bad idea. Tomorrow I get up to start my new job.
Anonymous Subs and Reference Counters
January 02, 2006 by Eric Richardson
I apologize to those of you who have no idea what I'm taking about in these coding posts. Just skip over them and you won't miss anything.
I had a breakthrough today in the whole memory leak issue when I realized that the way I am doing lazy initialization of some objects that I may or may not need but want available. The troublesome code:
# create system object
$swb->register('system',sub {
$self->_->new_object('System');
});
As long as that anonymous sub stays in existence, $self is sitting there as a reference and the calling object isn't going to fall out of scope. — Continue Reading...
GC And I Go Way Back
January 01, 2006 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...
Fun With Memory Leaks
January 01, 2006 by Eric Richardson
I mentioned recently that eThreads has memory leaks and that those leaks combined with a comment spam attack led to the system crashing while I was in South Carolina. I said at the time that the leak was "not big." Well, I think I have to retract that statement:
1: mem size: 20099072 change: 20099072
2: mem size: 20369408 change: 270336
3: mem size: 20635648 change: 266240
4: mem size: 20877312 change: 241664
5: mem size: 21114880 change: 237568
...
And the spam attacks haven't let up at all. It's only 3pm and so far today I've seen 8,033 comment spam attempts and 25,125 total page requests. Seeing as this blog really only averages maybe 115 or so pages a day right now (sorry for ignoring you lately), I tend to think those aren't human hits.
I'm blocking the spammers using lookups on the domains in the comments, but eThreads still runs most of the way through before processing that phase, so the damage gets done memory-wise (though not comment spam-wise, which is still a huge improvement). Tailing my access log for this blog roughly 1 in 3 accesses are comment spam. That's pretty crazy.
All this adds up to today being memory leak killing day.
Walking Around Downtown
January 01, 2006 by Eric Richardson
Random, but walking back to the apartment last night after going to check out the cancelled Giant Village D4 and I passed the Los Angeles Athletic Club. There was a charter bus parked out front and people were boarding. The last person we saw get in was none other than Pete Carroll. I attempted to take a picture, but it didn't come out well enough to be worth posting.