Posted on 2010-02-26 12:13:06.967669-08 by wpns
Out of memory with large numbers?
I'm testing each integer to see how many factors it has, and this works fine: @Factors = factors($fN); # every number has ONE and ITSELF as factors in addition to the ones found by factor() $NumFac = scalar(@Factors) + 2; But after a while it blows up, on numbers in excess of about 45 million, with an out of memory error. Any idea what's up? It's certainly much faster than my code to do ($fN % $loop) as loop runs from 1 to half of the number under test! Thanks!
Direct Responses: 12483 | Write a response
Posted on 2010-02-26 12:14:23.090846-08 by wpns in response to 12482
Re: Out of memory with large numbers?
Wow, I guess the code and slashcode tags are important:
@Factors = factors($fN); # every number has ONE and ITSELF as factors in addition to the ones found by factor() $NumFac = scalar(@Factors) + 2;
Direct Responses: 12486 | Write a response
Posted on 2010-02-26 14:33:08.033256-08 by wpns in response to 12483
Re: Out of memory with large numbers?
It may be even stranger than that, the above code steps by two, running code to step by one causes it to fall over after 27 million-ish iterations. Some kind of memory leak?
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.