[Linux-disciples] Fork error

Stephen R Laniel steve at laniels.org
Sun Feb 5 00:32:45 EST 2006


Doing this command:
for i in {1..5}; do echo $i; done
worked fine, as did this one:
for i in {1..500}; do echo $i; done

But this one did not:
for i in {1..1000000}; do echo $i; done

I got a lot of 'bash: fork: could not allocate memory'
errors. Which is bizarre to me. In my experience an
iterative command like that doesn't exhaust memory -- it
just takes a long time. And unless there's some recursion
happening internally, the amount of time it takes is just
linear with the size of the arguments. (Recursion leads to
memory exhaustion, which leads to swapping, which leads to
the process taking a long time to complete.)

So does anyone know bash well enough to explain why that
command didn't work?

-- 
Stephen R. Laniel
steve at laniels.org
Cell: +(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20060205/70c1886a/attachment.pgp


More information about the Linux-disciples mailing list