From owner-svn-src-all@FreeBSD.ORG Sun Jan 20 21:28:05 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id EE66019C; Sun, 20 Jan 2013 21:28:05 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C8DFF691; Sun, 20 Jan 2013 21:28:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0KLS568024324; Sun, 20 Jan 2013 21:28:05 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0KLS5rI024323; Sun, 20 Jan 2013 21:28:05 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201301202128.r0KLS5rI024323@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 20 Jan 2013 21:28:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r245698 - head/bin/sh X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Jan 2013 21:28:06 -0000 Author: jilles Date: Sun Jan 20 21:28:05 2013 New Revision: 245698 URL: http://svnweb.freebsd.org/changeset/base/245698 Log: sh: Move some stackmarks to fix high memory usage in some loops. If a loop contained certain commands (such as redirected compound commands), the temporary memory for the redirection was not freed between iterations of the loop but only after the loop. Put a stackmark in evaltree(), freeing memory whenever a node has been evaluated. Some other stackmarks are then redundant; remove them. Example: while :; do { :; } nfor.args ; argp ; argp = argp->narg.next) { oexitstatus = exitstatus; @@ -375,7 +377,6 @@ evalfor(union node *n, int flags) } } loopnest--; - popstackmark(&smark); exitstatus = status; } @@ -392,16 +393,13 @@ evalcase(union node *n) union node *cp; union node *patp; struct arglist arglist; - struct stackmark smark; - setstackmark(&smark); arglist.lastp = &arglist.list; oexitstatus = exitstatus; expandarg(n->ncase.expr, &arglist, EXP_TILDE); for (cp = n->ncase.cases ; cp ; cp = cp->nclist.next) { for (patp = cp->nclist.pattern ; patp ; patp = patp->narg.next) { if (casematch(patp, arglist.list->text)) { - popstackmark(&smark); while (cp->nclist.next && cp->type == NCLISTFALLTHRU && cp->nclist.body == NULL) @@ -415,7 +413,6 @@ evalcase(union node *n) } } } - popstackmark(&smark); exitstatus = 0; return (NULL); } @@ -610,7 +607,7 @@ evalbackcmd(union node *n, struct backcm { int pip[2]; struct job *jp; - struct stackmark smark; /* unnecessary */ + struct stackmark smark; struct jmploc jmploc; struct jmploc *savehandler; struct localvar *savelocalvars; @@ -751,7 +748,6 @@ safe_builtin(int idx, int argc, char **a static void evalcommand(union node *cmd, int flags, struct backcmd *backcmd) { - struct stackmark smark; union node *argp; struct arglist arglist; struct arglist varlist; @@ -778,7 +774,6 @@ evalcommand(union node *cmd, int flags, /* First expand the arguments. */ TRACE(("evalcommand(%p, %d) called\n", (void *)cmd, flags)); - setstackmark(&smark); arglist.lastp = &arglist.list; varlist.lastp = &varlist.list; varflag = 1; @@ -1149,7 +1144,6 @@ out: setvar("_", lastarg, 0); if (do_clearcmdentry) clearcmdentry(); - popstackmark(&smark); }