From: Dave Aronson Date: 2012-09-27T06:38:50+09:00 Subject: Re: Array Creation On Wed, Sep 26, 2012 at 3:47 PM, Tony Arcieri wrote: > You're probably doing an inaccurate comparison. You're asking Ruby to > allocate an array with 614,400,000 slots, which in C is equivalent to the > same number of pointers, which depending on whether you're on a 32-bit or > 64-bit host translates to either 2.4GB or 4.9GB. It's worse than that. ("He's dead, Jim!") In Ruby it's not just a straightforward memory allocation. The Array object itself needs additional setup, and for all I know there may be setup overhead for each individual slot. A closer (but still not quite direct) comparison would be to allocate memory for a huge string, such as: str = 'x' * 614400000 Depending on your character encoding settings, this might allocate anywhere from 0.6G to 2.4G; you can force it higher by using some obscure 32-bit character, or of course a longer initial string or higher number. > In general, I'd say the fact you're even attempting to do this is extremely > suspect. +1000! -Dave -- Dave Aronson, T. Rex of Codosaurus, LLC... aka Available Secret-Cleared Ruby/Rails Freelancer (NoVa/DC/Remote); see http://www.Codosaur.us/.