🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.misc.discuss
Article #74535

gawk memory infelicity (not quite a bug)

#74535
From: David H. West
Date: Fri, 19 Apr 1991 18:09
24 lines
1444 bytes
(Is there a more suitable newsgroup for this?)

Observed using gawk 2.02 beta (compiled for the IBM PC, not that that
should make any difference (?), and downloaded from SIMTEL):

Dynamic regular expression space seems not to be reclaimed, which
causes programs to run out of memory unnecessarily.

My program does the following for each input line:

{ if ($0 ~ r) {somestuff}
  else {someotherstuff}
}

r is a constant regexp passed from the command line, but it seems
to be recompiled at each use, and the space is not reclaimed, thus
causing execution to abort through lack of memory after 1100 lines
of input.  The same script, run with MKS awk, happily processes
18K lines of input without a problem.

Has this been fixed?  Is there a better way to write the script?
Is there a way to tell awk that r is constant?

-David West     dhw@iti.org
Technical Details
Message-ID: <1991Apr19.180929.10764@iti.org>
Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!lll-winken!iggy.GW.Vitalink.COM!widener!hela!dhw
References: <3348@charon.cwi.nl>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1025b4,a53b15fa10e4a4f5
X-Google-Attributes: gid1025b4,public
X-Google-ArrivalTime: 1991-04-19 14:57:32 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!lll-winken!iggy.GW.Vitalink.COM!widener!hela!dhw
From: dhw@iti.org (David H. West)
Newsgroups: gnu.misc.discuss
Subject: gawk memory infelicity (not quite a bug)
Message-ID: <1991Apr19.180929.10764@iti.org>
Date: 19 Apr 91 18:09:29 GMT
References: <3348@charon.cwi.nl>
Organization: The Forgotten Legions of ... um ... er ...
Lines: 24