Mailing List Archive

Memory leak?
I've run the following script on an IBM RS-6000 running AIX 3.2.5, an SGI
Iris 4D35 running IRIX 5.3, and a Sun SPARC 20, running Solaris 2.4.

for (1..1000000) { }

On all three machines the process takes up all the memory/swap space
available and then dies.

I'm running perl 5.001m on all three computers.

Here's the result of the myconfig command on the IBM:

Summary of my perl5 (patchlevel 1) configuration:
Platform:
osname=aix, osver=3.2.4, archname=aix
uname='aix zephyr 2 3 000018173800 '
hint=recommended
Compiler:
cc='cc', optimize='-O', ld='ld'
cppflags='-D_ALL_SOURCE'
ccflags ='-D_ALL_SOURCE'
ldflags =''
stdchar='unsigned char', d_stdstdio=define, usevfork=false
voidflags=15, castflags=1, d_casti32=define, d_castneg=undef
intsize=4, alignbytes=8, usemymalloc=y, randbits=15
Libraries:
so=so
libpth=/lib /usr/lib /usr/ccs/lib /usr/local/lib
libs=-ldbm -lld -lm -lc -lbsd -lPW
libc=/usr/lib/libc.a
Dynamic Linking:
dlsrc=dl_aix.xs, dlext=so, d_dlsymun=undef
cccdlflags=' ', ccdlflags='-bE:perl.exp', lddlflags='-H512 -T512 -bhalt:4 -bM:SRE -bI:$(PERL_INC)/perl.exp -bE:$(BASEEXT).exp -e _nostart -lc'

Here's the result of the myconfig command on the SGI:

Summary of my perl5 (patchlevel 1) configuration:
Platform:
osname=irix, osver=5, archname=IP12-irix
uname='irix eos 5.3 11091810 ip12 mips '
hint=recommended
Compiler:
cc='cc', optimize='-O', ld='ld'
cppflags='-D_POSIX_SOURCE -ansiposix -D_BSD_TYPES'
ccflags ='-D_POSIX_SOURCE -ansiposix -D_BSD_TYPES -Olimit 3000'
ldflags =''
stdchar='unsigned char', d_stdstdio=define, usevfork=false
voidflags=15, castflags=1, d_casti32=define, d_castneg=undef
intsize=4, alignbytes=8, usemymalloc=y, randbits=15
Libraries:
so=so
libpth=/usr/lib /usr/local/lib /lib
libs=-lsun -lm -lc -lcrypt -lbsd -lPW
libc=/usr/lib/libc.so
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef
cccdlflags=' ', ccdlflags=' ', lddlflags='-shared'

Here's the result of the myconfig command on the Sun:

Summary of my perl5 (patchlevel 1) configuration:
Platform:
osname=solaris, osver=2.4, archname=sun4-solaris
uname='sunos ciocc 5.4 generic sun4m sparc '
hint=recommended
Compiler:
cc='cc', optimize='-O', ld='cc'
cppflags=''
ccflags =''
ldflags =''
stdchar='unsigned char', d_stdstdio=define, usevfork=false
voidflags=15, castflags=0, d_casti32=define, d_castneg=define
intsize=4, alignbytes=8, usemymalloc=y, randbits=15
Libraries:
so=so
libpth=/lib /usr/lib /usr/ccs/lib /usr/local/lib
libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
libc=/usr/lib/libc.so
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef
cccdlflags='-Kpic', ccdlflags=' ', lddlflags='-G'


Donald Johnson Technical Support Division
Voice: (916)445-0962 California Air Resources Board
Fax: (916)327-8524 e-mail: donp@arb.ca.gov
Re: Memory leak? [ In reply to ]
> From: "Donald P. Johnson" <donp@zephyr.arb.ca.gov>
>
> I've run the following script on an IBM RS-6000 running AIX 3.2.5, an SGI
> Iris 4D35 running IRIX 5.3, and a Sun SPARC 20, running Solaris 2.4.
>
> for (1..1000000) { }
>
> On all three machines the process takes up all the memory/swap space
> available and then dies.

It's a feature. Perl creates the list of values before iterating.

Tim.
Re: Memory leak? [ In reply to ]
On Thu, 12 Oct 1995 08:35:21 PDT, "Donald P. Johnson" wrote:
>I've run the following script on an IBM RS-6000 running AIX 3.2.5, an SGI
>Iris 4D35 running IRIX 5.3, and a Sun SPARC 20, running Solaris 2.4.
>
>for (1..1000000) { }
>
>On all three machines the process takes up all the memory/swap space
>available and then dies.
>
>I'm running perl 5.001m on all three computers.
>

This leaks badly even with Larry's eval-of-string-leak patch on SunOS 4.1.3.
This explains some rather mystifying memory consumption in some of my old
daemons that I stopped running.

Just when I thought all of them had been plugged.

- Sarathy.
gsar@engin.umich.edu
Re: Memory leak? [ In reply to ]
>From: Gurusamy Sarathy <gsar@engin.umich.edu>
>On Thu, 12 Oct 1995 08:35:21 PDT, "Donald P. Johnson" wrote:
>>I've run the following script on an IBM RS-6000 running AIX 3.2.5, an SGI
>>Iris 4D35 running IRIX 5.3, and a Sun SPARC 20, running Solaris 2.4.
>>
>>for (1..1000000) { }
>>
>>On all three machines the process takes up all the memory/swap space
>>available and then dies.
>>
>>I'm running perl 5.001m on all three computers.
>>
>
>This leaks badly even with Larry's eval-of-string-leak patch on SunOS 4.1.3.
>This explains some rather mystifying memory consumption in some of my old
>daemons that I stopped running.

This is not a memory leak. It is a non-optimization that has been known
about (and complained about) back at least as far as perl 2.0. Perl is
trying to actually build the list (1,2,3,4,...,1000000) before looping
over it. It is already on Larry's wish list that such for-loops need to be
implemented in some lazy way to avoid this problem, but it has a very low
priority because there is such a simple work around (I.e., use the other
form of for-loop "for ($i=1;$i<=1000000;$i++)").

Again, there is not memory leak. If it actually executed, the memory would
be reclaimed (of course the memory high water mark would never be the same
again.)

--
Mark Biggar
mab@wdl.lroal.com
Re: Memory leak? [ In reply to ]
On Thu, 12 Oct 1995 10:09:16 PDT, Mark A Biggar wrote:
>
>This is not a memory leak. It is a non-optimization that has been known
>about (and complained about) back at least as far as perl 2.0. Perl is
>trying to actually build the list (1,2,3,4,...,1000000) before looping
>over it. It is already on Larry's wish list that such for-loops need to be
>implemented in some lazy way to avoid this problem, but it has a very low
>priority because there is such a simple work around (I.e., use the other
>form of for-loop "for ($i=1;$i<=1000000;$i++)").
>
>Again, there is not memory leak. If it actually executed, the memory would
>be reclaimed (of course the memory high water mark would never be the same
>again.)
>

Huhhuh, I should've guessed. Didn't know about this non-optimization.

Thanks.

>--
>Mark Biggar
>mab@wdl.lroal.com
>

- Sarathy.
gsar@engin.umich.edu