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

Re[2]: High memory usage on // substitution in one situation, normal usage in other



Good evening, Ladies and Gentlemen,

I can reproduce the extraordinary high memory usage (until the process is killed) of Sebastian's first code example with zsh-5.3.1-88-gd8c66e6 running on Linux; but only if EXTENDEDGLOB is set.

Best regards,
Manuel.




Bart Schaefer hat am 21.05.2017 um 13:03 folgendes geschrieben:

> On May 21,  9:28am, Sebastian Gniazdowski wrote:
> }
> } following will cause like 55 GB of VIRT memory usage (process will
> } be killed), having RES memory at 1.8 MB, which roughly equals to
> } ${#__text}.
>
> I can't reproduce this.  The for loop takes a lot longer to create the
> array than does the simple assignment, but neither example uses a huge
> amount of memory.
>
> Since you had a "local -A arr2" in your first example, I ran each of
> the examples in an anon function in a fresh shell.  I also tried the
> second example both with "local -a arr" added, and as you posted it,
> but that didn't really make any difference.
>
> On my system, the associative arr2 case looks like this:
>
> swap    free
> 412780  81244
> (skip gradual shrinking during "for" loop)
> 412780  33260
> 412780  33260
> 412780  58668
>
> The second like this:
>
> swap    free
> 412780  81420
> 412780  38092
> 412780  36748
> 412780  36772
> 412780  31524
> 412780  22692
> 412780  66532
>
> The $__text value is global in both cases so the delta between the first
> and last "free" numbers is the memory consumed by that plus any unused
> space in the last unpopped zsh heap block.
>
> In both cases the // expression is almost instantaneous, much faster than
> creating the $__text string in the first place.  Neither uses any swap.
> My config.h defines HAVE_MMAP 1, so the zsh heap is allocated as an
> anonymous mapfile, but I don't have 55GB free on the filesystem so I
> don't think that can be a factor.





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