"I have no way around this as it has to exist in my code"
Alter your code so that you don't need it. You only have one piece of meaningful data here, the number 693530740
, which fits just fine into 8 bytes. It is very unlikely that you really need to expand it into that huge array. Most of Ruby's array methods that you might think you need will have equivalents (using Range
, or Enumerator
) that work without needing to instantiate such a list of numbers.
If you have trouble seeing what kind of re-design would avoid the large array, then post a new question - here on Stack Overflow if the design can be outlined in a short description and a few lines of code. Perhaps to codereview.stackexchange.com if it not possible to demonstrate your algorithm in a small piece of code.