On Jun 30, 2010, at 6:52 PM, Craig A. Berry wrote: > > On Jun 28, 2010, at 4:32 PM, Mark Berryman wrote: > >> Sometime between Perl 5.8.6 and 5.12.1 a memory leak was introduced into >> Perl and it appears to be in the glob function. The following should >> reproduce the problem on any VMS system: >> >> @dirs = glob('SYS$COMMON:[000000]*.DIR'); >> >> for (;;) { >> foreach (@dirs) { >> s|\[000000\]|\[|; >> $_ = substr($_, 0, rindex(uc($_), '.DIR')) . ']'; >> @files = glob($_ . '*.*;*'); >> } >> } >> >> Execute this and then repeatedly hit control-T to watch your memory >> consumption climbing. Let it run long enough and it will eventually abort >> due to insufficient virtual memory. >> > > I can confirm that it chews memory pretty fast (about 4,000 pages every 5 > seconds on my rx2600). There is a Perl_vms_start_glob() function in > [.vms]vms.c if anyone is hankering after a session with the heap analyzer and > wants to know where to look. I hope to look into this at some point but > can't commit to when. >
I found it. In VMS.C, the routine Perl_flex_stat_int allocates memory twice without ever releasing it. Here are the two instances: fileified = PerlMem_malloc(VMS_MAXRSS); temp_fspec = PerlMem_malloc(VMS_MAXRSS); Simply adding the appropriate calls to PerlMem_free at the exit point seems to have fixed the problem.