+ Adding Abhishek Hi Chen and Abhishek, it seems you might work on the same team since you sent the exact same bug report:
- http://lists.gnu.org/archive/html/bug-bash/2018-12/msg00059.html - http://lists.gnu.org/archive/html/bug-bash/2018-12/msg00058.html - http://lists.gnu.org/archive/html/bug-bash/2018-12/msg00057.html On Wed, Dec 19, 2018 at 6:45 AM jake <chen.liu.opensou...@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? > 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. 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.