Subject: | memory leaks in sqlite_db_disconnect |
DBD::SQLite leaks memory in sqlite_db_disconnect.
Follow is a recurrence code. This code leaks memory in each loop.
use strict;
use warnings;
use DBI;
while (1) {
my $dbh = DBI->connect('dbi:SQLite:dbname=/tmp/foo.sqlite', undef,
undef, {AutoCommit => 1, RaiseError => 1}) or die $DBI::errstr;
$dbh->disconnect;
}
I think av_undef does not free the memory.
follow is a patch.
=== dbdimp.c
==================================================================
--- dbdimp.c (revision 21926)
+++ dbdimp.c (local)
@@ -157,9 +157,11 @@
imp_dbh->db = NULL;
av_undef(imp_dbh->functions);
+ SvREFCNT_dec(imp_dbh->functions);
imp_dbh->functions = (AV *)NULL;
av_undef(imp_dbh->aggregates);
+ SvREFCNT_dec(imp_dbh->aggregates);
imp_dbh->aggregates = (AV *)NULL;
return TRUE;