serow@octavia.ibix.co.jp (Yoshitomo Tanaka) (02/13/91)
In perl 3 patchlevel 44, the following script causes memory leak. #! /usr/bin/perl &xtest; system("ps v"); #eat memory &xtest; system("ps v"); #eat more memory &xtest; system("ps v"); #eat more and more memory &xtest; system("ps v"); #eat more and more and more memory &xtest; system("ps v"); #eat more ((and more) x 3) memory sub xtest { for ($i = 0; $i < 10000; $i++) { $s = " " x ($i % 100); } } __END__ -------------------- -+--+- Yoshitomo Tanaka serow@ibix.co.jp | ' \---
lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (02/14/91)
In article <SEROW.91Feb13170202@octavia.ibix.co.jp> serow@octavia.ibix.co.jp (Yoshitomo Tanaka) writes:
:
: In perl 3 patchlevel 44,
: the following script causes memory leak.
:
: #! /usr/bin/perl
: &xtest; system("ps v"); #eat memory
: &xtest; system("ps v"); #eat more memory
: &xtest; system("ps v"); #eat more and more memory
: &xtest; system("ps v"); #eat more and more and more memory
: &xtest; system("ps v"); #eat more ((and more) x 3) memory
: sub xtest {
: for ($i = 0; $i < 10000; $i++) {
: $s = " " x ($i % 100);
: }
: }
Oops, you're right. Forgot to free a temporary scalar. Fixed in 4.0. Thanks.
Larry
usenet@carssdf.UUCP (John Watson) (02/17/91)
Lary, While you are fixing up 4.0, please look for a memory leak in eval, possibly you are not freeing up tmpstr? Also please update your perldb to include something like: *** /usr/lib/perl/perldb.pl Wed Jan 23 10:53:39 1991 --- perldb.pl Sun Jan 13 19:25:08 1991 *************** *** 499,511 **** push(@stack, $single); $single &= 1; $single |= 4 if $#stack == $deep; if (wantarray) { ! @i = &$sub; $single |= pop(@stack); @i; } else { ! $i = &$sub; $single |= pop(@stack); $i; } --- 494,507 ---- push(@stack, $single); $single &= 1; $single |= 4 if $#stack == $deep; + local(@args) = @_; if (wantarray) { ! @i = &$sub(@args); $single |= pop(@stack); @i; } else { ! $i = &$sub(@args); $single |= pop(@stack); $i; } So that we can pass arguments to a "usersub" defined subroutine. I think this code used to be there about a dozen revisions back. Thanks, John Watson rutgers!carssdf!usenet
lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (02/19/91)
In article <284@carssdf.UUCP> usenet@carssdf.UUCP (John Watson) writes:
: Lary, While you are fixing up 4.0, please look for a memory leak in
: eval, possibly you are not freeing up tmpstr?
The only memory leak in eval I'm aware of is that if the eval fails, I
don't currently attempt to free the syntax tree. If there's some other
problem, could you mail me a test case?
: Also please update your perldb to include something like:
:
: *** /usr/lib/perl/perldb.pl Wed Jan 23 10:53:39 1991
: --- perldb.pl Sun Jan 13 19:25:08 1991
: ***************
: *** 499,511 ****
: push(@stack, $single);
: $single &= 1;
: $single |= 4 if $#stack == $deep;
: if (wantarray) {
: ! @i = &$sub;
: $single |= pop(@stack);
: @i;
: }
: else {
: ! $i = &$sub;
: $single |= pop(@stack);
: $i;
: }
: --- 494,507 ----
: push(@stack, $single);
: $single &= 1;
: $single |= 4 if $#stack == $deep;
: + local(@args) = @_;
: if (wantarray) {
: ! @i = &$sub(@args);
: $single |= pop(@stack);
: @i;
: }
: else {
: ! $i = &$sub(@args);
: $single |= pop(@stack);
: $i;
: }
:
:
: So that we can pass arguments to a "usersub" defined subroutine. I think
: this code used to be there about a dozen revisions back.
Unfortunately, this would break all scripts that pass arguments by reference.
The right way to handle it is simply not to call the debugging subroutine
on usersub routines. That entails a fix to do_subr().
Larry
lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (02/22/91)
In article <284@carssdf.UUCP> usenet@carssdf.UUCP (John Watson) writes:
: Larry, While you are fixing up 4.0, please look for a memory leak in
: eval, possibly you are not freeing up tmpstr?
That turned out to be the tr/// memory leak problem, I believe. There
were a couple of other small eval leaks I plugged too, though I don't
know if you would have run into them.
Larry
piet@cs.ruu.nl (Piet van Oostrum) (06/24/91)
The following script shows a memory leak. The leak disappears if either the local or the directory calls (or both :=) are removed This is perl, version 4.0 $RCSfile: perl.c,v $$Revision: 4.0.1.4 $$Date: 91/06/10 01:23:07 $ Patch level: 10 Copyright (c) 1989, 1990, 1991, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 4.0 source kit. Note: this is with perl's malloc. #!/usr/bin/perl sub try { local (*F); opendir(F, "."); @files = readdir(F); closedir(F); } while (1) { & try; } -- Piet* van Oostrum, Dept of Computer Science, Utrecht University, Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands. Telephone: +31 30 531806 Uucp: uunet!mcsun!ruuinf!piet Telefax: +31 30 513791 Internet: piet@cs.ruu.nl (*`Pete')