Hi,

it seems that the mail <[email protected]> from Michal
and also my mail <[email protected]> about some
regressions are missed on ast-developers.

Also I'd like to add some found results about endless growing memory
for daemonized shell scripts using sub shells and/or sub processes.

For detection I'm using an awk script [first attachment] and strace
together with two shell scripts [second and third attachment].

On 64bit systems (here x86_64 with page size 4kB) I found e.g.

  gubaidulina:tmp # ksh -c 'echo ${.sh.version}'
  Version JM 93u+ 2012-01-01
  gubaidulina:tmp # strace  -o '|./vmbalance' ksh leak1.sh
  [leak1.sh: leak count at 7]
  385024 bytes with 10 chunks allocated and 0 chunks freed
  gubaidulina:tmp # strace  -o '|./vmbalance' ksh leak2.sh
  [leak2.sh: leak count at 59]
  778240 bytes with 14 chunks allocated and 0 chunks freed

and if I choose a locale not necessarily with UTF-8

  gubaidulina:tmp # LANG=en_US strace  -o '|./vmbalance' ksh leak1.sh 
  [leak1.sh: leak count at 4000]
  83255296 bytes with 2540 chunks allocated and 1 chunks freed
  gubaidulina:tmp # LANG=en_US strace  -o '|./vmbalance' ksh leak2.sh
  [leak2.sh: leak count at 4000]
  398778368 bytes with 4169 chunks allocated and 1 chunks freed

that is that ksh 93u+ 2012-01-01 its memory is growing over time
by using shell loops with sub shells and with locale other than POSIX
the problem is much more fatal.


   Werner

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr
#!/usr/bin/awk -f
#
# vmblance      Awk script to detect endless growing memory alloctions
#               in endless shell loops using in daemonized shell scripts
#
# Usage:
#
#   strace -e mmap,mmap2,munmap -o './vmblance' ksh leak1.sh
#
BEGIN {
    FS="([[:blank:]]|[[:punct:]])"
    ignore=""
    sum=0
    allocs=0
    frees=0
}
/^mmap(2|64)?\(/ {
   if ($0 !~ /.*MAP_PRIVATE\|MAP_ANONYMOUS.*/) {
        if (ignore)
            ignore=ignore "|" $NF
        else
            ignore=$NF
   } else {
        sum+=$4
        allocs++
   }
}
/^munmap(2|64)?\(/ {
   if ($0 !~ ignore) {
        sum-=$4
        frees++
   }
}
END {
    print sum " bytes with " allocs " chunks allocated and " frees " chunks 
freed"
}

Attachment: leak1.sh
Description: application/shellscript

Attachment: leak2.sh
Description: application/shellscript

_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to