How are 2D static arrays allocated?

Saaa empty at needmail.com
Tue Nov 4 08:41:33 PST 2008


>
> You can have a dynamic array that _points_ to the stack, but there is
> no general mechanism for allocating a dynamic array directly on the
> stack.  You might be able to do something with alloca, but stack space
> is usually limited and you wouldn't be able to have very large arrays.
>
> Performance of dynamic arrays is the same no matter where their data
> is.  Fixed-size 2D arrays are not faster _because_ they are on the
> stack, they just happen to be allocated on the stack.  They are faster
> (usually) because they don't need two pointer dereferences.  You can
> allocated a fixed-size 2D array on the heap (well.. inside a struct or
> class anyway) and it will be just as fast.

Ok, so when I want a multimillion array with speed I should use a static
array on the heap. That would be using new, right :) 




More information about the Digitalmars-d-learn mailing list