I am also running out of memory before the loop completes.
What is your idea of $aref in that loop that bombs off? Is it an integer, or an array reference? What it the result of adding 1 to an array reference? or 2 ? What happens to an array (or array reference) if you index it with the result of that addition?
my $aref = []; print $aref,"\n"; print $aref + 1,"\n"; print $aref + 2,"\n"; print "mem: ",qx{ps -o vsz= $$}; $aref[$aref +2] = "foo"; print "mem: ",qx{ps -o vsz= $$}; __END__ ARRAY(0xf5dba0) 16112545 16112546 mem: 28964 mem: 154844
By converting the hexadecimal address of $aref to integer - this is what happens if you add an integer to it - and using it then as an index, you extend @data and pre-allocate slots, each containing a NULL value. If the address of $aref is high enough, your program hits the memory limit of your machine.
In reply to Re: Running out of memory while running this for loop
by shmem
in thread Running out of memory while running this for loop
by Ppeoc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |