Good or best way to allocate a large array

All basic Methods in Array (especially #new) are implemented in C, so
I don't think you will gain a lot. Implementing the whole algorithm in
C might be worthwhile, because you would bypass using a Ruby object for
every slot, but the Array is not the issue here.

As others have shown, it works reasonably quick.

Regards,
Florian

···

On Nov 10, 2009, at 4:25 PM, Jonathan Schmidt-Dominé - Developer wrote:

What's about using C or C++ to allocate and deallocate the array? I do not
think Ruby was made to create such Arrays.

Jonathan,

What's about using C or C++ to allocate and deallocate the array? I do not
think Ruby was made to create such Arrays.

Yes, I am beginning to come to such a conclusion. Now I have to
figure out how to interface the two. The Ruby book is good ... but a
Windows-based example of adding two numbers together and returning the
result would be even better. :slight_smile:

Hi!

I thaught about allocation and deallocation from C. And I think there you have
more control over GC and the heap.

The User

Why are you so insisting on a database? In contrast to your opinion,
there are valid cases where an in-memory array is just what you want.

Varnish for example is an interesting example that uses data structures
in that magnitude.

Regards,
Florian Gilcher

···

On Nov 10, 2009, at 4:50 PM, Marnen Laibow-Koser wrote:

Jonathan Schmidt-Dominé - Developer wrote:

What's about using C or C++ to allocate and deallocate the array?

Unnecessary. Just use a database.

Florian Gilcher wrote:

Jonathan Schmidt-Domin� - Developer wrote:

What's about using C or C++ to allocate and deallocate the array?

Unnecessary. Just use a database.

Why are you so insisting on a database?

Because almost any array that large is better dealt with through a DB
interface.

In contrast to your opinion,
there are valid cases where an in-memory array is just what you want.

How about an in-memory DB? SQLite can function that way.

Varnish for example is an interesting example that uses data structures
in that magnitude.

Varnish is a caching package, not what most people will want to
implement. Besides, if the OP were implementing something like Varnish,
I suspect he'd be knowledgeable enough that he wouldn't have asked the
question in the first place.

Best,

···

On Nov 10, 2009, at 4:50 PM, Marnen Laibow-Koser wrote:

--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org

Regards,
Florian Gilcher

--
Posted via http://www.ruby-forum.com/\.