Subject: | PersistentSearch Memory Issue |
Date: | Wed, 3 Apr 2013 09:09:45 -0700 |
To: | bug-perl-ldap [...] rt.cpan.org |
From: | Jeffrey Dunham <jeffrey.a.dunham [...] gmail.com> |
I use Persistent search to query our change log and do some actions based
off of that.
Checking the heap of my process it gets large, growing pretty quick ( LDAP
is changed extremely often here so our changelog is large ) after 2 days
for example I am using 8 GB of memory and eventually my server starts
swapping
From what I can tell it appears persistentsearch is the culprit, I am using
perl 5.8 and Net::LDAP 0.53.
My code looks like:
$persist = Net::LDAP::Control::PersistentSearch->new(changeTypes => 1,
changesOnly => 0,
returnECs => 1 );
$sort = Net::LDAP::Control::Sort->new(order => "changeNumber");
if (defined $last_cn) {
my $next_cn = last_cn + 1;
$mesg = $ldapconn->search(
base => "cn=changelog",
filter =>
"(&(objectClass=changelogentry)(changeNumber>=$next_cn))",
callback => \&process_entry,
control => [ $persist , $sort ] );
die "error: ",$mesg->code(),": ",$mesg->error() if ($mesg->code());
}
This process simply eats memory. This is a child process that does this,
so what we've ended up doing is after a set amount of changes, we restart
the child, which does work, but it's a hacky solution.