Subject: | Memory leak in aio_scandir |
Daemon process using IO::AIO leaks, narrowed it down to aio_scandir with
the following minimal case:
-----
#!/usr/bin/perl
use IO::AIO;
use Devel::Leak;
print "IO::AIO Version: $IO::AIO::VERSION,\n";
my $handle;
my $count = Devel::Leak::NoteSV($handle);
aio_scandir $ENV{'HOME'}, 4, sub {
warn sprintf( "%d directories and %d others found\n\n",
scalar @{ $_[0] }, scalar @{ $_[1] } );
};
IO::AIO::poll_wait, IO::AIO::poll_cb while IO::AIO::nreqs;
Devel::Leak::CheckSV($handle);
-----
Output of the above:
IO::AIO Version: 3.6
74 directories and 134 others found
new 0x751d98 : SV = PV(0x654b78) at 0x751d98
REFCNT = 1
FLAGS = (POK,FAKE,READONLY,pPOK)
PV = 0x6913a0 "IO::AIO::REQ"
CUR = 12
LEN = 0
new 0x751db0 : SV = PVHV(0x7323a0) at 0x751db0
REFCNT = 1
FLAGS = (READONLY,SHAREKEYS)
ARRAY = 0x77a980 (0:6, 1:2)
hash quality = 125.0%
KEYS = 2
FILL = 2
MAX = 7
RITER = -1
EITER = 0x0
new 0x751dc8 : SV = PVGV(0x680ed0) at 0x751dc8
REFCNT = 1
FLAGS = (MULTI)
NAME = "DESTROY"
NAMELEN = 7
GvSTASH = 0x6fc818 "IO::AIO::REQ"
GP = 0x690280
SV = 0x0
REFCNT = 1
IO = 0x0
FORM = 0x0
AV = 0x0
HV = 0x0
CV = 0x0
CVGEN = 0x6
LINE = 976
FILE = "/usr/local/lib/perl/5.10.1/IO/AIO.pm"
FLAGS = 0x2
EGV = 0x751dc8 "DESTROY"
new 0x751de0 : SV = PVGV(0x680f00) at 0x751de0
REFCNT = 1
FLAGS = (MULTI)
NAME = "AUTOLOAD"
NAMELEN = 8
GvSTASH = 0x6fc818 "IO::AIO::REQ"
GP = 0x77b9d0
SV = 0x0
REFCNT = 1
IO = 0x0
FORM = 0x0
AV = 0x0
HV = 0x0
CV = 0x0
CVGEN = 0x6
LINE = 976
FILE = "/usr/local/lib/perl/5.10.1/IO/AIO.pm"
FLAGS = 0x2
EGV = 0x751de0 "AUTOLOAD"
new 0x751df8 : SV = NULL(0x0) at 0x751df8
REFCNT = 1
FLAGS = (PADSTALE,PADMY)
new 0x751e10 : SV = NULL(0x0) at 0x751e10
REFCNT = 1
FLAGS = (PADSTALE,PADMY)
new 0x748858 : SV = NULL(0x0) at 0x748858
REFCNT = 1
FLAGS = (PADSTALE,PADMY)
new 0x7489d8 : SV = PVAV(0x658080) at 0x7489d8
REFCNT = 1
FLAGS = (READONLY)
ARRAY = 0x77a950
FILL = 0
MAX = 3
ARYLEN = 0x0
FLAGS = (REAL)
new 0x748b28 : SV = NULL(0x0) at 0x748b28
REFCNT = 1
FLAGS = (PADSTALE,PADMY)
new 0x673690 : SV = PVGV(0x680e70) at 0x673690
REFCNT = 1
FLAGS = (MULTI)
NAME = "DESTROY"
NAMELEN = 7
GvSTASH = 0x6df4f8 "IO::AIO::GRP"
GP = 0x77a350
SV = 0x0
REFCNT = 1
IO = 0x0
FORM = 0x0
AV = 0x0
HV = 0x0
CV = 0x0
CVGEN = 0xa
LINE = 907
FILE = "/usr/local/lib/perl/5.10.1/IO/AIO.pm"
FLAGS = 0x2
EGV = 0x673690 "DESTROY"
new 0x6736a8 : SV = PVGV(0x680ea0) at 0x6736a8
REFCNT = 1
FLAGS = (MULTI)
NAME = "AUTOLOAD"
NAMELEN = 8
GvSTASH = 0x6df4f8 "IO::AIO::GRP"
GP = 0x77a3b0
SV = 0x0
REFCNT = 1
IO = 0x0
FORM = 0x0
AV = 0x0
HV = 0x0
CV = 0x0
CVGEN = 0xa
LINE = 907
FILE = "/usr/local/lib/perl/5.10.1/IO/AIO.pm"
FLAGS = 0x2
EGV = 0x6736a8 "AUTOLOAD"
old (1):
0 SV = UNKNOWN(0xff) (0x71ef18) at 0x667e70
REFCNT = 0
FLAGS = ()
old (1):
0 SV = UNKNOWN(0xff) (0x71f0b0) at 0x667b28
REFCNT = 0
FLAGS = ()
old (1):
0 SV = UNKNOWN(0xff) (0x656f40) at 0x667d20
REFCNT = 0
FLAGS = ()
old (1):
0 SV = UNKNOWN(0xff) (0x667b28) at 0x667d80
REFCNT = 0
FLAGS = ()
asackett@skunk:~/www-clients/emtl/scratch$ perl memory_leak_fix.pl
IO::AIO Version: 3.6,
74 directories and 134 others found
new 0x23c9d88 : SV = NULL(0x0) at 0x23c9d88
REFCNT = 1
FLAGS = (PADSTALE,PADMY)
new 0x23c9da0 : SV = PVAV(0x22d0080) at 0x23c9da0
REFCNT = 1
FLAGS = (READONLY)
ARRAY = 0x23f2ac0
FILL = 0
MAX = 3
ARYLEN = 0x0
FLAGS = (REAL)
new 0x23c9db8 : SV = PV(0x22ccc38) at 0x23c9db8
REFCNT = 1
FLAGS = (POK,FAKE,READONLY,pPOK)
PV = 0x2309390 "IO::AIO::REQ"
CUR = 12
LEN = 0
new 0x23c9dd0 : SV = PVHV(0x23aa390) at 0x23c9dd0
REFCNT = 1
FLAGS = (READONLY,SHAREKEYS)
ARRAY = 0x23f2af0 (0:6, 1:2)
hash quality = 125.0%
KEYS = 2
FILL = 2
MAX = 7
RITER = -1
EITER = 0x0
new 0x23c9de8 : SV = PVGV(0x22f8ec0) at 0x23c9de8
REFCNT = 1
FLAGS = (MULTI)
NAME = "DESTROY"
NAMELEN = 7
GvSTASH = 0x2374808 "IO::AIO::REQ"
GP = 0x2308270
SV = 0x0
REFCNT = 1
IO = 0x0
FORM = 0x0
AV = 0x0
HV = 0x0
CV = 0x0
CVGEN = 0x6
LINE = 976
FILE = "/usr/local/lib/perl/5.10.1/IO/AIO.pm"
FLAGS = 0x2
EGV = 0x23c9de8 "DESTROY"
new 0x23c9e00 : SV = PVGV(0x22f8ef0) at 0x23c9e00
REFCNT = 1
FLAGS = (MULTI)
NAME = "AUTOLOAD"
NAMELEN = 8
GvSTASH = 0x2374808 "IO::AIO::REQ"
GP = 0x23f3b40
SV = 0x0
REFCNT = 1
IO = 0x0
FORM = 0x0
AV = 0x0
HV = 0x0
CV = 0x0
CVGEN = 0x6
LINE = 976
FILE = "/usr/local/lib/perl/5.10.1/IO/AIO.pm"
FLAGS = 0x2
EGV = 0x23c9e00 "AUTOLOAD"
new 0x23c9e18 : SV = NULL(0x0) at 0x23c9e18
REFCNT = 1
FLAGS = (PADSTALE,PADMY)
new 0x23c9e30 : SV = NULL(0x0) at 0x23c9e30
REFCNT = 1
FLAGS = (PADSTALE,PADMY)
new 0x23b86f0 : SV = NULL(0x0) at 0x23b86f0
REFCNT = 1
FLAGS = (PADSTALE,PADMY)
new 0x22eb690 : SV = PVGV(0x22f8e60) at 0x22eb690
REFCNT = 1
FLAGS = (MULTI)
NAME = "DESTROY"
NAMELEN = 7
GvSTASH = 0x23574e8 "IO::AIO::GRP"
GP = 0x23f24c0
SV = 0x0
REFCNT = 1
IO = 0x0
FORM = 0x0
AV = 0x0
HV = 0x0
CV = 0x0
CVGEN = 0xa
LINE = 907
FILE = "/usr/local/lib/perl/5.10.1/IO/AIO.pm"
FLAGS = 0x2
EGV = 0x22eb690 "DESTROY"
new 0x22eb6a8 : SV = PVGV(0x22f8e90) at 0x22eb6a8
REFCNT = 1
FLAGS = (MULTI)
NAME = "AUTOLOAD"
NAMELEN = 8
GvSTASH = 0x23574e8 "IO::AIO::GRP"
GP = 0x23f2520
SV = 0x0
REFCNT = 1
IO = 0x0
FORM = 0x0
AV = 0x0
HV = 0x0
CV = 0x0
CVGEN = 0xa
LINE = 907
FILE = "/usr/local/lib/perl/5.10.1/IO/AIO.pm"
FLAGS = 0x2
EGV = 0x22eb6a8 "AUTOLOAD"
old (1):
0 SV = UNKNOWN(0xff) (0x22cef40) at 0x22dfd20
REFCNT = 0
FLAGS = ()
old (1):
0 SV = UNKNOWN(0xff) (0x22dfb28) at 0x22dfd80
REFCNT = 0
FLAGS = ()
old (1):
0 SV = UNKNOWN(0xff) (0x2397568) at 0x22dfe70
REFCNT = 0
FLAGS = ()
old (1):
0 SV = UNKNOWN(0xff) (0x2397640) at 0x22dfb28
REFCNT = 0
FLAGS = ()
OS is Debian squeeze on AMD64; perl is 5.10.1 from Debian repository,
IO::AIO is 3.6 from CPAN.