On 6/20/12 2:50 PM, Serge van den Boom wrote:

> Bash Version: 4.2
> Patch Level: 29
> Release Status: release
> 
> Description:
>       If you interrupt the evaluation of **/ wildcard expansion, the file
>       descriptors which were opened will not be closed.
>       Also, memory used will not be released.

I can't reproduce this:

$ echo $BASH_VERSION
4.2.29(5)-release
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.8 (Tikanga)
$ shopt -s globstar
$ ls -la /proc/self/fd
total 0
dr-x------ 2 chet wheel  0 Jun 23 16:07 ./
dr-xr-xr-x 6 chet wheel  0 Jun 23 16:07 ../
lrwx------ 1 chet wheel 64 Jun 23 16:07 0 -> /dev/pts/0
lrwx------ 1 chet wheel 64 Jun 23 16:07 1 -> /dev/pts/0
lrwx------ 1 chet wheel 64 Jun 23 16:07 2 -> /dev/pts/0
lr-x------ 1 chet wheel 64 Jun 23 16:07 3 -> /proc/28456/fd/
$ date
Sat Jun 23 16:07:34 EDT 2012
$ echo /**/*.txt
[^C here]
$ date
Sat Jun 23 16:08:51 EDT 2012
$ ls -la /proc/self/fd
total 0
dr-x------ 2 chet wheel  0 Jun 23 16:08 ./
dr-xr-xr-x 6 chet wheel  0 Jun 23 16:08 ../
lrwx------ 1 chet wheel 64 Jun 23 16:08 0 -> /dev/pts/0
lrwx------ 1 chet wheel 64 Jun 23 16:08 1 -> /dev/pts/0
lrwx------ 1 chet wheel 64 Jun 23 16:08 2 -> /dev/pts/0
lr-x------ 1 chet wheel 64 Jun 23 16:08 3 -> /proc/28553/fd/

Bash consuming memory is not evidence of a memory leak.  The bash malloc
only returns memory to the kernel under certain circumstances; it usually
acts as a cache between the application (bash) and the kernel.  You need
to run this using a leak-checking tool like valgrind to determine whether
bash has allocated memory to which it no longer retains a handle.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/



Reply via email to