Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Memory usage of history?

On Fri, Jun 24, 2016 at 6:47 AM, Dominik Vogt <vogt@xxxxxxxxxxxxxxxxxx> wrote:
> (A colleague
> says his zshs use 200 MB memory each with a history size of a
> million lines).

To expand on Eric's answer, zsh reads the entire $HISTFILE and retains
the last $HISTSIZE entries.  So a large $HISTFILE also slows down
startup, even if it doesn't consume lots of memory.

I can't imagine anyone having a million useful lines of history.  A
few tens of thousands at most.  Things he might consider that would
allow him to reduce SAVEHIST and/or HISTSIZE without losing too much
* Set the hist_ignore_all_dups option, if he doesn't already.
* Set the hist_save_no_dups option, similarly.
* Define a zshaddhistory function to filter out commands that are
unlikely to be used again.

If he isn't already ignoring / not saving duplicates, an interesting
experiment might be to add hist_ignore_all_dups without changing
HISTSIZE, then run zsh and see how many lines of history actually end
up being retained.

Messages sorted by: Reverse Date, Date, Thread, Author