fish-shell / fish-shell

The user-friendly command line shell.

Home Page:https://fishshell.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

large memory usage when run large lines code

unisgn opened this issue · comments

fish --version
3.7.1

run.sh
this file simply contains 100k lines of
echo 0
and a line of
sleep 100

run it with
fish run.sh

the fish takes about 40MB of mem.

why?

The file is ~800K large, fish reads it all and stores it internally as UTF-32, so it's 3.2M just for that. It parses the entire file upfront (unlike other shells - this has the advantage that fish will complain about syntax errors without running a broken script) and keeps it in memory. Then it runs it and stores a bunch of other information.

I'm going to close this issue. It's about an extreme edge case - a 100K long file isn't normal, you're asking about a very much synthetic example. And even in that case, I do not believe 40M is typically a practical issue (it is half the memory of my emacs configuration with that file open, and about the same as emacs without configuration. it would probably be less than the browser tab you're reading this comment in).

So because there is nothing specifically actionable I see no need to keep this open. That doesn't mean we're not going to accept improvements to memory usage, or look for them, just that there's no specific bug here.