Subject: | Memory leak when leaving 'each' loop prematurely |
Date: | Fri, 28 Mar 2014 15:15:15 -0700 |
To: | bug-DBM-Deep [...] rt.cpan.org |
From: | Terris Linenbach <terris [...] terris.com> |
Hello,
Thanks for DBM::Deep! It's very useful.
use DBM::Deep;
my %db;
tie %db, "DBM::Deep", "foo.db";
$db{ 'a' } = { 'b' => { } };
untie %db;
for ( ;; ) {
tie %db, "DBM::Deep", "foo.db";
my $hash = $db{'a'};
while ( each %{$hash} ) {
last;
}
untie %db;
}
If you comment out the 'last' in the while loop, the leak will disappear. I
also tied the next_key API. That didn't fix the problem. I tried many
things - e.g., weaken, calling keys on the 'a' hash, using OO instead of
tie, closing via stuff like "tied %db->engine->close" and on and on (I
spent several days working on alternatives). The only thing that fixes the
leak is to use "each" all the way to the end of the hash prior to untie.
This isn't a special case. For me, it happens to every hash stored in
DBM::Deep.
Thanks,
Terris