From: Tridib Bandopadhyay Date: 2012-09-27T04:32:43+09:00 Subject: Re: Array Creation Dave Aronson wrote in post #1077665: > On Wed, Sep 26, 2012 at 3:21 PM, Tridib Bandopadhyay > wrote: > >> names = Array.new(614400000) > ... >> Ruby took around 308 seconds to create this large array. Can anyone tell >> me why Ruby takes such a long time? > > Precisely BECAUSE it's so large! You may well have been running out > of memory, needing to swap RAM out to disk, which is very very slow. > Whatever you were intending to do with such a huge array, would > probably benefit from a good hard look at alternative algorithms, > especially focusing on dealing with only a small subset of the data at > one time. > > -Dave OK, but when i declare same array with my extension using a simple malloc() function. It takes very less time. Is there any internal mechanism goes on when Ruby creates an array by itself?. Thank You -- Posted via http://www.ruby-forum.com/.