saahbs has asked for the wisdom of the Perl Monks concerning the following question:
The code below appears to leak memory.
The leak rate is high when connections are refused. (tested using perl v5.8.8 as shipped in GNU/Debian Linux Etch with 2.6.22 kernel) Thanks, Mike
#!/usr/bin/perl use warnings; use strict; use Socket qw(:DEFAULT IPPROTO_TCP TCP_NODELAY); while ( 1 ){ socket(Client, PF_INET, SOCK_STREAM, getprotobyname("tcp")) or die " +ERROR: socket() failed $!\n"; my $remoteAddr = sockaddr_in(1220, inet_aton("localhost")) or die "E +RROR: sockaddr_in() failed $!\n"; connect(Client, $remoteAddr) or print "connect() status: $!\n"; close(Client) or print "DEBUG: close() status: $!\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: socket leaks memory
by Joost (Canon) on Oct 02, 2007 at 18:47 UTC | |
|
Re: socket leaks memory
by kyle (Abbot) on Oct 02, 2007 at 18:07 UTC | |
by saahbs (Initiate) on Oct 02, 2007 at 18:21 UTC | |
|
Re: socket leaks memory
by saahbs (Initiate) on Oct 02, 2007 at 17:40 UTC | |
|
Re: socket leaks memory
by saahbs (Initiate) on Oct 02, 2007 at 19:04 UTC |