From: Peter Zotov Date: 2012-09-27T14:54:05+09:00 Subject: Re: Array Creation Dave Aronson писал 27.09.2012 01:38: > 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. There is none. The whole slot range is allocated with one xmalloc(): http://rxr.whitequark.org/mri/source/array.c#319 -- WBR, Peter Zotov.