mathics-core
mathics-core copied to clipboard
Memory exhaustion calculating very large integers
Is your feature request related to a problem? Please describe. The following program from https://oeis.org/A000643 causes mathics to use over 10GB of RAM, and I end up having to kill it to avoid it from exhausting all the memory on my machine:
Off[General::ovfl];
a={1,0};
Flatten[Prepend[Table[s=Plus@@a;a=2^(RotateLeft[a]);a[[ -1]]=s,{n,8}],
Table[0,{m,Length[a]-1}]]]
To be fair, the program attempts to calculate an integer with over 5 million digits (inside the list a), which is why I'm not calling this a bug. But at the same time WMA handles this program completely fine, and gives a result almost immediately (it just takes a long time if you try to print the final value of a, but doesn't appear to use any substantial amount of memory)
Describe the solution you'd like Better memory efficiency for arbitrary precision arithmetic.
Describe alternatives you've considered Don't attempt to calculate numbers that are that big ;)