Subject: | Memory leak |
Hi,
We're using a build of perl 5.6.1, and Net::SSH::Perl 1.30 (not listed
on the 'rt' drop down list!) on various flavours of RedHat/Fedora.
We've been tracing a memory leak, which eventually has lead to a
subroutine which was creating a new Net::SSH::Perl object each time it
was called. However, when leaving the routine (and hence the scope of
the object), memory doesn't seem to be being released.
The problem can be demonstrated with the following simple script, which
will slowly consume more and more memory:
#!/packages/ksite/perl/bin/perl -w
use strict;
use Carp;
use Net::SSH::Perl;
while (1) {
my $sshhandle = new Net::SSH::Perl("infinistore.cinesite.co.uk",
(debug=>0, protocol=>1));
if ( ! defined $sshhandle ) {
croak("FATAL:: Unable to make ssh connection.\n");
}
$sshhandle->login("root",undef);
my ($out,$err,$exit)=$sshhandle->cmd('date');
if ( $exit ) {
my $message="FATAL:: Unable to open ssh connection. Error was ".$err;
croak ($message);
}
undef $sshhandle;
}
We're going to work around this for now by having a single
Net::SSH::Perl object, but as I understand things this code should work
Ok, and fully destroy all of the data associated with the object each
time round the loop?
Any help appreciated.
Danny