bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String replacements leak small amounts of memory each time


From: Chet Ramey
Subject: Re: String replacements leak small amounts of memory each time
Date: Sun, 13 Jun 2010 16:21:21 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.7) Gecko/20100111 Lightning/1.0b1 Thunderbird/3.0.1

On 6/13/10 11:17 AM, address@hidden wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: i486
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' 
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' 
> -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
> -DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2 
> -Wall
> uname output: Linux vampiric 2.6.32-3-686-bigmem #1 SMP Thu Feb 25 06:54:30 
> UTC 2010 i686 GNU/Linux
> Machine Type: i486-pc-linux-gnu
> 
> Bash Version: 4.1
> Patch Level: 5
> Release Status: release
> 
> Description:
>       When used in a script that iterates over several thousand lines of logs 
> or similar data, the bash string replacement functions seem to leak memory. 
> The Repeat-By list uses "ls -lR" to generate input, but any data will do (try 
> your system logs)
> 
> Repeat-By:
>       Start a shell, and start "top" or some other resource monitoring tool
> 
>       Try one of the following:
>       while read line; do test=${line%%/*}; done < <(ls -lR)
>       while read line; do test=${line//a/b}; done < <(ls -lR)
>       while read line; do test=${line#\ }; done < <(ls -lR)
> 
>       Also, geirha in #bash on irc.freenode.net suggested:
>       var=x; for j in {1..50}; do ps -osize=,vsize= -p $$; for i in 
> {1..1000}; do var=${var%%*/}; done; done;

valgrind detects no memory leaks for any of these cases.


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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]