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

Re: 24948: max size of an array ?



Didn't send this to the list, again...

Marc Chantreux <marc.chantreux@xxxxxxxxxxxxxxxxxx> wrote:
> I noticed that the max size of an array is 24948. Is it right ? Is there 
>   a way to work around ?

The number in the code currently says 262144, but yes, there's a limit.

I'm not at all sure it's right.  It was added as an entirely arbitrary
limit to prevent people crashing the shell by assigning to large array
elements, with no correlation to the actual amount of memory available.
The correct fix would be for the shell to fail gracefully when it couldn't
allocate memory, but that's quite tricky to handle in all circumstances.
Second-guessing user behaviour with a fixed limit is somewhat fraught.

It would be fairly straightforward to make the limit configurable via a
parameter such as ZSH_MAX_ARRLEN.  This would have to be a special
parameter for efficiency (we test this quite a lot deep in the
parameter code).

I suppose then we'd have people complaining they set ZSH_MAX_ARRLEN to
several zillion and then the shell crashed when they tried to allocate an
array.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php



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