From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3/2) with ESMTP id FAA23406 for ; Tue, 11 Jun 1996 05:16:48 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id PAA28701; Mon, 10 Jun 1996 15:04:31 -0400 (EDT) Resent-Date: Mon, 10 Jun 1996 15:04:31 -0400 (EDT) From: Zoltan Hidvegi Message-Id: <199606101905.VAA07171@bolyai.cs.elte.hu> Subject: Re: HISTSIZE To: hniksic@srce.hr (Hrvoje Niksic) Date: Mon, 10 Jun 1996 21:05:20 +0200 (MET DST) Cc: zsh-workers@math.gatech.edu In-Reply-To: from Hrvoje Niksic at "Jun 8, 96 10:17:43 pm" Organization: Dept. of Comp. Sci., Eotvos University, Budapest, Hungary Phone: (36 1)2669833 ext: 2667, home phone: (36 1) 2752368 X-Mailer: ELM [version 2.4ME+ PL16 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"VTrlS1.0.N07.v67ln"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1315 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu > I have noticed that when I set HISTSIZE (the maximum size of the > history list) in zsh to something huge, zsh takes huge amounts of > memory. > > When I converted from bash, I have easily ported all the init files, > and HISTSIZE caused terrible problems (especially since I didn't know > HISTSIZE was causing them). The reason I set HISTSIZE to such a big > value is just to keep it from bothering me -- it is just a *maximum* > value I am changing. In bash it worked exactly that way (no additional > memory expense). But it seems that the organization of history storage > requires resizehistevents() to reallocate the list to HISTSIZE history > entries. > > I wonder how difficult would it be to patch hist.c in such a way that > the actual size of the history list changes dynamically, HISTSIZE > being only an upper limit to that change. Zsh uses a HISTSIZE long array to store history entries. gethistent(X) is defined as (histentarr+((X)%histentct)) (with proper bounds checking at apropriate places). This is usually the most compact representation. A linked list can be used but then the pointers would require extra memory. histentarr is almost full in most cases since it is filled from $HISTFILE upon invocation. Most people do like to limit the number of stored history events since loading and saving big histories takes a long time. Of course SAVEHIST can be smaller than HISTSIZE but most people do not issue more than 1000 commands from one shell so HISTSIZE = SAVEHIST + 1000 should be enough. Zoltan