Re: Declaring local variables inside while loop leads to memory leak

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

 



On Tue, Jul 26, 2016 at 01:35:53PM +0300, Vladimir Didenko wrote:
> I found that declaring local variables inside while loop leads to
> memory leak. Code sample:

> test()
> {
>    while [ true ]; do
>       local a=
>    done
> }

> test

This can indeed consume a lot of memory. The memory is freed when the
function returns.

This could be fixed by adding a check before making a variable local but
that might make functions with many distinct locals slower.

Also note that the problem does not occur if local is used at the top of
a function only, as recommended by the man page.

-- 
Jilles Tjoelker
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux