Skip Menu |

This queue is for tickets about the BerkeleyDB CPAN distribution.

Report information
The Basics
Id: 90134
Status: open
Priority: 0/
Queue: BerkeleyDB

People
Owner: Nobody in particular
Requestors: david [...] cobite.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: memory leak in CDS locking routines
Date: Thu, 07 Nov 2013 16:06:00 -0500
To: bug-BerkeleyDB [...] rt.cpan.org
From: David Mansfield <david [...] cobite.com>
I've finally tracked down a leak which has bothered me for years! In the package BerkeleyDB::CDS::Lock (in BerkeleyDB.pm), there are two "global" hashes, %Object and %Count. These hashes are keyed by the stringification of the $db object. Entries in these hashes are never deleted, even when the $db object is long gone. This only matters if new $db are being created and destroyed. In my long-running perl daemon, the leak only really becomes significant after months! Some kind of: delete $BerkeleyDB::CDS::Lock::Count{"$db"}; delete $BerkeleyDB::CDS::Lock::Object{"$db"}; is needed, probably when the Count hits 0. -- Thanks, David Mansfield Cobite, INC.
Hey David, thanks for the big report. Your analysis is spot on - the Count & Object data structures are not being clean up properly. The code below, from BerkeleyDB.pm, is how I'm going to fix the code if you want to try it out. Will upload an update to CPAN once I smoke test the fix. sub cds_unlock { my $self = shift ; my $db = $self->[0] ; if ($self->[1]) { $self->[1] = 0 ; -- $Count{"$db"} if $Count{"$db"} > 0 ; if ($Count{"$db"} == 0) { $Object{"$db"}->c_close() ; delete $Object{"$db"}; delete $Count{"$db"}; } return 1 ; } return undef ; } Paul
BerkeleyDB 0.54 just uploaded to CPAN. Hope that sorts the issue. Paul