[comp.lang.perl] Perl process size grows and grows

gwaters@bwdls35.bnr.ca (Glenn Waters) (11/08/90)

When the following program is run the process size keeps growing.
I do not understand why. Actually, I must run a loop much larger than
10000 and then I run out of swap when running this program!

				  SIZE
                                   |
				   V
13879 p2 S     0:00  0  1      0  100  444    xx  7.7  1.9 perl ttt
13884 p2 S     0:00  0  0      0   32  180    xx  0.0  0.8 grep perl
13879 p2 R     0:02  0  5      0 1660  448    xx 52.8  1.9 perl

The broken program...

#!/usr/local/bin/perl
@name = ("name1", "name2", "name3", "name4");

&dum (*name);

system ("ps -acxv | grep 'UID'");
system ("ps -vacx | grep 'perl'");
for ($i = 0; $i < 10000; $i++)
{
  &dum (*name);
}
system ("ps -acxv | grep 'perl'");

#********* Sub Dum ********
sub dum
{
  local (*anything) = @_;
}
-- 
Glenn Waters, Network Systems Support         gwaters@bnr.ca
Bell-Northern Research, Ltd.                  ...!uunet!bwdls35!gwaters
P.O. Box 3511, Station C                      (613)763-3933 (Voice)
Ottawa Ontario Canada K1Y 4H7                 (613)763-3283 (FAX)
#include <disclaimer.h>

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (11/08/90)

In article <1990Nov7.200342.12853@bwdls61.bnr.ca> gwaters@bwdls35.bnr.ca (Glenn Waters) writes:
: When the following program is run the process size keeps growing.
 
: The broken program...
: 
: #!/usr/local/bin/perl
: for ($i = 0; $i < 10000; $i++)
: {
:   &dum (*name);
: }
: 
: #********* Sub Dum ********
: sub dum
: {
:   local (*anything) = @_;
: }

Yup, it's a bona fide leak.  I don't see any workaround, offhand.
But it will be fixed in 38.  Thanks.

If you're desperate, apply the following, and expect the corresponding
hunk of 38 to fail:

*** /tmp/,RCSt1009402	Wed Nov  7 17:25:42 1990
--- str.c	Wed Nov  7 17:15:22 1990
***************
*** 590,595 ****
--- 601,608 ----
  #ifdef TAINT
      str->str_tainted = nstr->str_tainted;
  #endif
+     if (nstr->str_magic)
+ 	str_free(nstr->str_magic);
      Safefree(nstr);
  }
  
Larry