memory usage increases with redirection on loop

Michael Tokarev mjt at tls.msk.ru
Wed Oct 10 09:06:34 UTC 2012


On 10.10.2012 12:56, walter harms wrote:
> Am 09.10.2012 23:08, schrieb Jon Tollefson:
>> I have an ash script that I have stripped down to its simplest form
>> below that still exhibits the behavior.  While the script is running
>> under busybox I look at 'top' output in another window and see the RES
>> column for busybox slowly increasing.  The testing I have been doing is
>> under Linux.
>>
>> If I remove the redirection after the 'done' then it doesn't show this
>> memory increase.  Or if I move it to the front of the while such as "cat
>> /dev/null | while true" then it also doesn't show the memory usage
>> increasing.  Still it seems the case below shouldn't be increasing
>> memory usage either.
>>
>> Jon
>>
>>
>> while true
>>   do
>>     while true
>>       do
>>         break;
>>     done</dev/null
>> done
>>
> 
> hi Jon,
> to reproduce that we need a .config and a version number for busybox.

This happens on a current 1.20.2 version, I just reproduced it
locally.  There's apparently no memory leaks, but valgrind is
helpful still:

==20170== 4,883,404 bytes in 9,613 blocks are still reachable in loss record 15 of 15
==20170==    at 0x48CF308: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==20170==    by 0x804EE8B: xmalloc (xfuncs_printf.c:47)
==20170==    by 0x806EC96: stalloc (ash.c:1417)
==20170==    by 0x806ED00: stzalloc (ash.c:1434)
==20170==    by 0x8071A22: expandarg (ash.c:7271)
==20170==    by 0x8071ADE: expredir (ash.c:8666)
==20170==    by 0x8073455: evaltree (ash.c:8401)
==20170==    by 0x80744D2: evalloop (ash.c:8534)
==20170==    by 0x8073546: evaltree (ash.c:8454)
==20170==    by 0x8074916: cmdloop (ash.c:12185)
==20170==    by 0x80761ED: ash_main (ash.c:13224)
==20170==    by 0x804E143: run_applet_no_and_exit (appletlib.c:755)

This is after a few seconds of execution.  With more execution
time, this number of blocks increases rapidly, and so is the
process memory size.

Without redirection this piece is not growing.

Thanks,

/mjt


More information about the busybox mailing list