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

Re: How to add string to end of each array element without loops



On Mar 26,  3:37am, nix@xxxxxxxxxxxxxxxx wrote:
}
} Now however, im getting a segfault when an array elements exceeds over
} 4 million elements even there are enough RAM in my box.

A segfault doing what, exactly?  Perhaps run with:

exec 2>/tmp/zsh$$trace
setopt xtrace

I can create and reference arrays of that size without a problem:

schaefer<523> typeset -A a
schaefer<524> a=({4000000..1} {1..4000000})
schaefer<525> echo $#a
4000000
schaefer<526> a=({5000000..1} {1..5000000})
schaefer<527> echo $#a
5000000

and then after noodling around a bit:

schaefer<533> b=($a)
schaefer<534> echo $#b
5000000

even if I guarantee there are multiple simultaneous copies of the array:

schaefer<535> foo() { local -a c; c=($b); print $#c }
schaefer<536> foo
5000000

so it's not something magic about 4 million.

} Is there a way to increase this limit? There was nothing to that with
} 'limit' command.

The limit command (and ulimit) deal with OS-imposed limitations on the
resource usage of a process.  It's entirely possible that it's one of
those that you're running up against, but difficult to guess which one
without knowing what the shell was doing at the moment of failure.

Generally speaking zsh doesn't impose any of its own restrictions except
for function recursion depth and number of simultaneous monitored jobs
(both of which are limited to 1000).



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