Front page | perl.perl5.porters |
Postings from May 2003
[perl #22071] socketpair() leaks memory
Thread Next
From:
perlbug-followup
Date:
May 1, 2003 05:52
Subject:
[perl #22071] socketpair() leaks memory
Message ID:
rt-22071-56271.11.4643098737993@bugs6.perl.org
# New Ticket Created by pacman@clss.net
# Please include the string: [perl #22071]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=22071 >
This is a bug report for perl from pacman@gkar.clss.net,
generated with the help of perlbug 1.34 running under perl v5.8.0.
-----------------------------------------------------------------
[Please enter your report here]
Socketpair() allocates 4 buffers (I assume that's one input and one output
buffer for each socket) but it only frees 1 of them when each socket is
closed, leaving 2 unused buffers behind. If you just create the socketpair
and close the sockets without using them, it doesn't leak as fast (buffers
are lazy-allocated when used?)
This demo program shows the leak, with minimal use of modules (to prove that
the leak is really in the core).
The leak appears to be new - I can't reproduce it in 5.6.1, but that might be
because I don't have perlio enabled on the 5.6.1.
#!/usr/bin/perl -w
use strict;
use Socket; # Only for AF_UNIX and SOCK_STREAM!
$/="\r";
$|=1;
for(my $i=0;;++$i) {
socketpair(SOCK1, SOCK2, AF_UNIX, SOCK_STREAM, 0);
if($ENV{LEAKFASTER}) {
select(SOCK1); $|=1; select(STDOUT);
print SOCK1 "$i\r";
print STDOUT scalar <SOCK2>;
} else {
print "$i\r";
}
close(SOCK1);
close(SOCK2);
# On my machine, the following gives a report on memory usage of the perl
# process after every 100th iteration, which demonstrates constant growth.
#print("\n"), system("ps mp$$") unless $i % 100;
}
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=high
---
Site configuration information for perl v5.8.0:
Configured by pacman at Fri Apr 25 21:52:06 EST 2003.
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=linux, osvers=2.2.20, archname=i386-linux
uname='linux gkar 2.2.20 #1 sat apr 20 11:45:28 est 2002 i586 unknown '
config_args='-Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i386-linux -Dprefix=/usr -Dprivlib=/usr/share/perl/5.8.0 -Darchlib=/usr/lib/perl/5.8.0 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.8.0 -Dsitearch=/usr/local/lib/perl/5.8.0 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Duseshrplib -Dlibperl=libperl.so.5.8.0 -Dd_dosuid -des'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O3',
cppflags='-DDEBIAN -fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='2.95.4 20011002 (Debian prerelease)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldbm -ldb -ldl -lm -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
libc=/lib/libc-2.2.5.so, so=so, useshrplib=true, libperl=libperl.so.5.8.0
gnulibc_version='2.2.5'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl/5.8.0/CORE'
cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'
Locally applied patches:
---
@INC for perl v5.8.0:
/usr/lib/perl/5.8.0
/usr/share/perl/5.8.0
/usr/local/lib/perl/5.8.0
/usr/local/share/perl/5.8.0
/usr/local/share/perl
/usr/lib/perl5
/usr/share/perl5
/usr/share/perl5
.
---
Environment for perl v5.8.0:
HOME=/home/pacman
LANG=C
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/home/pacman/bin
PERL_BADLANG (unset)
SHELL=/bin/zsh
Thread Next
-
[perl #22071] socketpair() leaks memory
by perlbug-followup