Subject: | Memory leak |
This simple script does an HTTP request with ::INET or ::SSL. The $server variable has to be set to some test server of your own that can take the DoSing that this script inflicts on it.
#!perl
warn $$;
use IO::Socket::INET;
use IO::Socket::SSL;
$server = 'put your own server here';
if (shift()) {
$mod = "IO::Socket::SSL";
$port = 443
}
else {
$mod = "IO::Socket::INET";
$port = 80
}
while (1) {
my $sock = new $mod
PeerAddr => $server, PeerPort => $port,
or die $!;
$sock->autoflush();
print $sock
"GET / HTTP/1.1\r\nHost: $server\r\nContent-Length: 0\r\n\r\n";
my $response = join '', <$sock> or die $!;
}
__END__
If you save it as ‘test’, then
$ perl test
will run it with ::INET and
$ perl test 1
will run it with ::SSL.
If you run ‘top’ in a separate window, you can see that the memory usage stays constant with ::INET, but constantly increases with ::SSL.
This is with IO::Socket::SSL version 2.047 and Net::SSLeay version 1.80. I see the same results with both perl 5.14.0 and perl 5.24.0.
On another perl installation (5.10.1), I have IO::Socket::SSL 1.31 and Net::SSLeay 1.35, and there is no memory leak.
I was trying to switch a long-running script over to doing secure connections, but it could never run to completion, as it would get killed after reaching 10GB of memory usage. So for now I have switched it back to using HTTP, which I don’t really want to do, but is currently my only choice.