in reply to A script with a loop is running my computer Out of memory

Billions of scalars would certainly blow out your memory since you only have a very few billion bytes of RAM and there is overhead.

If you're going to merely sum over all the children in @generation, why not simply do $generation{$outerLoopIndex +1} += int(rand(6)); directly, and avoid burning all that memory on very temporary values?