Skip to main content
4 of 6
added 68 characters in body
jlliagre
  • 62.5k
  • 11
  • 123
  • 162
i=0
while true; do
a[$i]=foo
i=$((i+1))
printf "\r%d " $i
done

This simple script shows on my systems (Gnu/Linux and Solaris):

  • ksh88 limits the size to 2^12-1 (4095). (subscript out of range ). Some older releases like the one on HP-UX limit the size to 1023.

  • ksh93 limits the size of a array to 2^22-1 (4194303), your mileage may vary.

  • bash doesn't look to impose any hard-coded limit outside the one dictated by the underlying memory resources available. For example bash uses 1.3 GB of virtual memory for an array size of 18074340.

Note I gave up with mksh which was too slow executing the loop (more than one hundred times slower than zsh, ksh93 and bash.)

jlliagre
  • 62.5k
  • 11
  • 123
  • 162