List:MySQL and Perl« Previous MessageNext Message »
From:John Heitmann Date:January 10 2003 2:40am
Subject:Mem leak upon recovering after a disconnect
View as plain text  
Hello,

In our mod_perl app we came across this rather nasty memory leak. I 
assume it is from DBD::mysql judging from the source, but if it's a DBI 
thing I can take it to that list.

This loop leaks at least a page of memory per iteration:

for my $i (1..1000) {
	my $dbh = DBI->connect(...);
	$dbh->disconnect();
	$dbh->do(something);
	sleep(1);
}

A small 4kb per iteration isn't the limit to how bad this leak is, we 
saw multiple megabytes per iteration leak in our full production setup. 
It is easy to workaround once we found the problem, we just check the 
Active flag before we do anything. Finding the problem took quite 
awhile though :-(

I understand that the above construct is dubious. There is a good 
explanation I won't get into as to how it came about. I'm not 
necessarily asking for the leak to get fixed, but if it doesn't get 
fixed I think the above should error out or give a warning.

I'll be happy to work up a patch to fix the leak or add a warning if 
someone could point me at the right places in the source to dive in, I 
didn't have much luck finding the right spot to start my attack.

Thanks,

John

Thread
Mem leak upon recovering after a disconnectJohn Heitmann10 Jan
  • Re: Mem leak upon recovering after a disconnectJochen Wiedmann10 Jan
    • Re: Mem leak upon recovering after a disconnectJohn Heitmann10 Jan