Mailing List Archive

eval leaks memory at a consistent rate
I ran into this while writing a table-driven parser using hashes of
'keyword' => 'code-to-eval'. I wracked my code trying to figure out how
*I* was causing the leak. Finally, the idea hit me (in the shower, no
less :) that eval was responsible. So, here is the proverbial one-line
test case:

eval '1' while(1);

It takes about 2 minutes to consume the available VM on my Sparc ELC.

I'm running perl 5.001m compiled with gcc 2.7 (using system as & ld for
-pic support). Of historical note: it happens with perl 4.036 as well.

Cheers!

-- sky G.

Summary of my perl5 (patchlevel 1) configuration:
Platform:
osname=sunos, osver=4.1.3_u1, archname=sun4-sunos
uname='sunos scisdn9 4.1.3_u1 3 sun4c '
hint=recommended
Compiler:
cc='gcc', optimize='-O'
cppflags=''
ccflags ='-B/bin/'
ldflags ='-B/bin/'
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=31
Libraries:
so=so
libpth=/lib /usr/lib /usr/ucblib /usr/local/lib
libs=-lnsl -ldbm -ldl -lm -lc -lposix
libc=/usr/lib/libc.so.1.9
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=
cccdlflags='-fpic', ccdlflags=' ', lddlflags='-assert nodefinitions'
Re: eval leaks memory at a consistent rate [ In reply to ]
On Thu, 26 Oct 1995, Sky Golightly wrote:

> I ran into this while writing a table-driven parser using hashes of
> 'keyword' => 'code-to-eval'. I wracked my code trying to figure out how
> *I* was causing the leak. Finally, the idea hit me (in the shower, no
> less :) that eval was responsible. So, here is the proverbial one-line
> test case:
>
> eval '1' while(1);
>
> It takes about 2 minutes to consume the available VM on my Sparc ELC.

Have a look in ftp://ftp.perl.com/pub/perl/src/patches/ and see if
eval-leak.patch helps :-) I *think* that failed evals still leak, but am
subject to my usual human failings.

Mike

--
Mike Stok | The "`Stok' disclaimers" apply.
stok@pencom.com | Pencom Systems Administration (work)
stok@cybercom.net | Cyber Access (play)
http://www.cybercom.net/~stok/ | The inevitable WWW page (?)
Re: eval leaks memory at a consistent rate [ In reply to ]
On Thu, 26 Oct 1995, Sky Golightly wrote:

> I ran into this while writing a table-driven parser using hashes of
> 'keyword' => 'code-to-eval'. I wracked my code trying to figure out how
> *I* was causing the leak. Finally, the idea hit me (in the shower, no
> less :) that eval was responsible. So, here is the proverbial one-line
> test case:
>
> eval '1' while(1);
>
> It takes about 2 minutes to consume the available VM on my Sparc ELC.

Have a look in ftp://ftp.perl.com/pub/perl/src/patches/ and see if
eval-leak.patch helps :-) I *think* that failed evals still leak, but am
subject to my usual human failings.

Mike

--
Mike Stok | The "`Stok' disclaimers" apply.
stok@pencom.com | Pencom Systems Administration (work)
stok@cybercom.net | Cyber Access (play)
http://www.cybercom.net/~stok/ | The inevitable WWW page (?)
Re: eval leaks memory at a consistent rate [ In reply to ]
do you have the famed eval patch?

(see //perl.com/pub/perl/src/patches/)
Re: eval leaks memory at a consistent rate [ In reply to ]
: Have a look in ftp://ftp.perl.com/pub/perl/src/patches/ and see if
: eval-leak.patch helps :-)

It should.

: I *think* that failed evals still leak, but am
: subject to my usual human failings.

Depends on whether the eval fails with allocated stuff in the yacc stack.
(Now that we're using byacc consistently, it might be possible to unwind
the stack properly, but nobody's looked at it.)

Larry