Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Eduardo Bustamante Newsgroups: gnu.bash.bug Subject: Re: Memory continusely increase Date: Wed, 19 Dec 2018 09:58:16 -0800 Lines: 66 Approved: bug-bash@gnu.org Message-ID: References: <1545199834453-0.post@n7.nabble.com> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: usenet.stanford.edu 1545242313 32348 208.118.235.17 (19 Dec 2018 17:58:33 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash To: jake , abhishpaliwal@gmail.com Envelope-to: Bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KuEqS1XTlVQkTAmJ0yuNB5Xbk9IL/SWFtODcA+B3IY4=; b=nC8Bq1Ljrr0Rgfr3BqK61PlfO/04I7rlJTz7/vAxSYI+lNexSzP1I3MmmrBc/ToPdi o93wQdoV59ZZX61w7FnS9JQ/bqerizNNdPQCX3IYs7W6WC9o5g974JTGLM4GDbFYMz5l r99vvybc6sA5BZMZUiSTMF3Ytg+OyL5dZ6+Sjx1Wx4QhwZXXWUlvRNGqmmIna2CYd4Fa i54eu9cIvazwlxzInafuXJ67sXhyiBNqs9l10lG8Q+J7JJcWYlXZc0xDTQA1whV3EklP FImxbzWx2h6H6DO4HEDkVla4dOmBOu4k9Hc8IHK4xrsOXX2qton4wRkks4hW4rN5E3P+ x0WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KuEqS1XTlVQkTAmJ0yuNB5Xbk9IL/SWFtODcA+B3IY4=; b=NlEjXGXvRFvq+Qy41f5U9IjDnRgTgHKDdYx1khGJrcNZ8mIssTrOfqWB2b2vldL0tj 3hpUsWJzWob/hWSM4pXsFFqFmxcGhxNA+USTxioV8lEJB2BTFL15XMs5/iG5zlkizTSQ cZWtjZCVcjFQgsWzYkzGrPaZ8wS6XvIvPzg5D8sRed/f4wF9bj6l/eVwjJD/7C2i1nXK K7XTBrmARbzIVgdDEpuxdbeektMHQ+p8f6LouQG7gt5lTpFrg41h4Q7JhQdfYLV9mBbs 6m/YsCVioXQ/wZJu9+dp825CVO3s+vEIeTnGzjan7v1cm3UW/1Zsn69D+ajh9C1uV2Vz XB4A== X-Gm-Message-State: AA+aEWaJo2kI2NE64/Txuu/99Z6J8jc+B34YiIBf3j9cjksSTlH2v30Q IwsBV4t40CdoR8uyTz/PpL5MQPjsMxcjuq2VBnd76heZ X-Google-Smtp-Source: AFSGD/WgATkykTa8silFknWXZFN33BoPM9pzgy3J6fFFPEVE3ZZ9vxC0FSjuf++dEugv8gu3xdnkdJI5kdWF60as6h0= X-Received: by 2002:a2e:868c:: with SMTP id l12-v6mr14667793lji.90.1545242307526; Wed, 19 Dec 2018 09:58:27 -0800 (PST) In-Reply-To: <1545199834453-0.post@n7.nabble.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::241 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14928 + 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 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.