bug-bash
[Top][All Lists]
Advanced

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

Re: Memory continusely increase


From: chen liu
Subject: Re: Memory continusely increase
Date: Thu, 20 Dec 2018 11:31:36 +0800

Eduardo Bustamante <dualbus@gmail.com> 于2018年12月20日周四 上午1:58写道:
>
> + Adding Abhishek

> On Wed, Dec 19, 2018 at 6:45 AM jake <chen.liu.opensource@gmail.com> wrote:
> >
> > Hi all,
> >
> > I did a test about run a bash scriplt never quit,but met a memory usage
> > issue that cause used memory continuous increase.
> > This issue was present in bash-3.2.x, bash-4.0.x, bash-4.1.x, bash-4.2.x,
> > bash-4.3.x. However, This issue was disappeared in bash-4.4.0, I can't trace
> > which patch fixed the issue or which new feature was introduced in
> > bash-4.4.0.
>
> These versions (3.2, 4.0, 4.1, 4.2 and 4.3) are fairly old. Any
> particular reason you're not upgrading to 4.4 instead?

It has deployed to our devices, so if direct upgrade to bash-4.4, we
need spend about
one year to verify it.

>
> > Could someone help to tell me which part of changes in bash-4.4.0, that
> > would be give me a direction backport code changes from bash-4.4 to
> > bash-3.2.x and bash-4.3.x.
>
> (...)
>
> > while(true);do
> >  while (true); do
> >    ls > /dev/null
> >  done
> > done
>
> My guess is that it's a memory leak in subshell creation. You don't
> need that subshell by the way, the following should work just fine:
>
> while :; do
>  ...
> done
>
> The parenthesis are not only not needed, but they add overhead because
> a new subshell is created every time.

This issue still present even remove the parenthesis.
As you said, the memory leak in subshell creation. The subshell create
in every loop and
that scirpt is infinite loop that would be cause create many Child
processes, maybe there
have some resource don't be release when the child process has exited.

below is the calling process:
________________________________________

execute_command_internal() (loop-start)
              |
execute_in_subshell()
              |
execute_command_internal()
              |
execute_simple_command()
              |
execute_command_internal()
              |
execute_simple_command()
              |_________(loop-start)
__________________________________


> Anyways, looking at the changelog for 4.4, it looks like it's going to
> be time consuming to find / backport this, since there are many memory
> leaks that were fixed:
>
> $ grep -i leak ./CHANGES-4.4
> c.  Fixed several memory leaks.
> a.  Fixed a memory leak when processing ${!var[@]}.
> i.  Fixed a memory leak in the code that removes duplicate history entries.
> b.  Fixed a memory leak in programmable completion.
> i.  Fixed a memory leak when processing declare commands that perform compound
> s.  Fixed a memory leak that occurred when interrupting brace expansions
> dd. Fixed a memory leak when creating local array variables and assigning to
> p.  Fixed a potential file descriptor leak when dup2() fails while performing 
> a
> i.  Some memory leaks caused by signals interrupting filename completion have
>
>
> I'll try to go through some of these changes later today to see if
> anything evident comes up. I still recommend just upgrading to 4.4 if
> you can though. Running outdated versions is never fun.

Thanks for your efforts:)

Thanks,
Chen.



reply via email to

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