From: Robert Klemme Date: 2009-11-10T23:09:48+09:00 Subject: Re: Good or best way to allocate a large array 2009/11/10 Florian Gilcher : > The thing is that an Array of size (300_000*20) already has as many > slots for references. So it's not "initializing references". It just > makes every field of the Array referencing that one BigNum. There is > no allocation or initialization happening in this step. Right. Only the single BigNum and the Array need to be allocated. > As you correctly stated, the first example allocs (300_000*20 + 1) > objects. The interesting point in this is that it triggers the > GC more than once, although there is nothing to collect. Well, but this is expected: the second example has more need for memory (every time a new BigNum must be created), and if memory is needed it is reasonable to first start GC before asking the OS for more memory. GC cannot know that it will not find anything collectible. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/