2015-02-04 19:55 GMT-02:00 Paulo César Pereira de Andrade <paulo.cesar.pereira.de.andr...@gmail.com>: > Hi, > > (Not attaching to make it easier to view archives) > > I have this test case: > > ---8<--- > #!/bin/ksh93 > > # exec > test3.out 2>&1 > unset PATH FPATH CDPATH > > print "Test 3: Alleges a memory leak: unset is not properly freeing > members of an associative array" > > alarm -r do_status +3 > function do_status.alarm > { > printf "%(%H:%M:%S)T Iteration $i\n" > /bin/ps -o vsz,pid,comm -p $$ > } > > > typeset -A stuff > > typeset -lui i=0 > for (( i=0; i<1000000; i++ )) > do > unset stuff[xyz] > typeset -A stuff[xyz] > stuff[xyz][elem0]="data0" > stuff[xyz][elem1]="data1" > stuff[xyz][elem2]="data2" > stuff[xyz][elem3]="data3" > stuff[xyz][elem4]="data4" > stuff[xyz][elem5]="data5" > stuff[xyz][elem6]="data6" > stuff[xyz][elem7]="data7" > stuff[xyz][elem8]="data8" > stuff[xyz][elem9]="data9" > stuff[xyz][elem9]="data9" > done > ---8<--- > > It leaks every iteration. I found that using unset -f would > fix it, but the apparently proper patch would is: > > ---8<--- > diff -up ksh-20120801/src/cmd/ksh93/bltins/typeset.c.orig > ksh-20120801/src/cmd/ksh93/bltins/typeset.c > --- ksh-20120801/src/cmd/ksh93/bltins/typeset.c.orig 2015-02-04 > 11:05:20.376445293 -0200 > +++ ksh-20120801/src/cmd/ksh93/bltins/typeset.c 2015-02-04 > 11:05:23.781449724 -0200 > @@ -1242,7 +1242,6 @@ static int unall(int argc, char **argv, > #endif /* SHOPT_FIXEDARRAY */ > { > r=1; > - continue; > } > > if(shp->subshell) > ---8<---
Please ignore the proposed patch. It does not work. I got confused with different tests, because "unset -f stuff[xyz]" causes it to not leak. But that is becasue "unset -f" has the same effect as of commenting the "unset stuff[xyz]" line. In other words, if unset is used, it will leak. Thanks, Paulo _______________________________________________ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users