Hi,
it seems there is some memory leak when ksh works with arrays.
Reproducer script (attached) takes more and more memory
and iterations take more and more time:
0.26 total kB 123360 7120 5404
0.26 total kB 128416 12180 10464
0.26 total kB 133472 17236 15520
0.26 total kB 138528 22292 20576
0.26 total kB 143616 27364 25648
0.26 total kB 148672 32424 30708
0.27 total kB 153728 37484 35768
0.27 total kB 158784 42540 40824
0.28 total kB 163840 47596 45880
0.28 total kB 168896 52656 50940
0.29 total kB 173952 57712 55996
0.30 total kB 179008 62768 61052
0.31 total kB 184064 67828 66112
0.32 total kB 189120 72884 71168
0.33 total kB 194208 77956 76240
0.35 total kB 199264 83012 81296
0.34 total kB 204320 88072 86356
0.35 total kB 209376 93132 91416
0.35 total kB 214432 98192 96476
...
Happens in both latest stable release and latest
alpha.
Using unset in the function prevents this problem:
0.27 total kB 118336 2092 356
0.27 total kB 118336 2092 356
0.27 total kB 118336 2092 356
0.27 total kB 118336 2092 356
0.27 total kB 118336 2092 356
0.27 total kB 118336 2092 356
0.27 total kB 118336 2092 356
0.27 total kB 118336 2092 356
0.27 total kB 118336 2092 356
...
Let me know if you need more information.
Michal
#!/usr/bin/ksh
function _hash {
typeset w=([abc]=1 [def]=31534 [xyz]=42)
print -u2 $w 2>&-
# accessing the var will leak
}
function _array {
typeset w=(1 31534 42)
print -u2 $w 2>&-
# unset w will prevent leak
}
print ${.sh.version}
pmap -x $$ |tail -1
for (( j=0; j<100; j++)); do
START=$SECONDS
for (( i=0; i<10000; i++)); do
_array
# _hash #choose one
done
printf "%.2f\t" $((SECONDS-$START))
pmap -x $$ |tail -1
done
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers