Closed vovpov closed 12 years ago
That's weird. Can you provide me with more information - OS, perl and Moose version. A working script would be ideal. I will look on this problem tomorrow. Thank you for reporting this.
Ok, I was able to reproduce it myself with the following code:
use 5.010;
use strict;
use warnings;
use RedisDB;
for (1..10) {
my $redis = RedisDB->new;
$redis->set('test', $_);
}
say "Check connections";
<>;
Indeed connections stay open
The problem was introduced by 1.03 when I extracted parser into a separate module. Parser keeps a reference to the parent RedisDB object, and so prevents it from destruction. I just uploaded RedisDB-1.06 with the fix. Thanks again for the report.
Hello. There is a such kind of situation: I have a (moose) class that encapsulates RedisDB object. Objects of this class frequently creating and destroying - but after destroying i see that running process accumulates open sockets. It seems that when main object destroed, attribute with RedisDB not cleared yet. First i try write in my class next code: sub DEMOLISH { my $self = shift; $self->redis(undef) if defined $self->redis; } But this is not help. Next i try to write DESTROY method in your class like: sub DESTROY
{
my $self = shift;
$self->{_socket}->close() if defined $self->{_socket};
}
and in my class i write in destructor $self->redis->DESTROY; After that problems disappear and sockets closed after object destroying. So maybe you need to add explicit DESTROY method in your class? or maybe i do something wrong )