Counting Very Large Numbers - Ran Out of Memory


I’m writing a simple test program that starts with a very large number (5,000,000,000). It then runs through a few filtering conditional loops and stores numbers into an array, which then get printed. The array will hold thousands of numbers.

I get an error like this:
“fatal error: allowed memory size of 94371840 bytes exhausted (tried to allocate 71 bytes)”

Does anyone know of a way to run this script and cut back on memory usage?


Without seeing the code there isn’t much advice to give you other than to make sure you’re clearing out old values at some point. If you’re simply adding numbers to an array until you’re out of memory nothing is really going to help.