"The total size of a static array cannot exceed 16Mb."
BCS
ao at pathlink.com
Tue Oct 2 08:12:41 PDT 2007
Reply to Vladimir,
> On Tue, 02 Oct 2007 10:16:25 +0300, BCS <ao at pathlink.com> wrote:
>
>> Reply to Vladimir,
>>
>>> Why?
>>>
>>> I posted a bug report yesterday, thinking it was just some
>>> accidentally left over code.
>>>
>>> But I noticed this statement in the documentation today. And,
>>> frankly, I don't understand why that limitation is there.
>>>
>>> The problem with this restriction comes when using multi-dimensional
>>> arrays. Branched dynamic arrays are MUCH slower than
>>> rectangular/cubic/etc. static arrays - and this is a severe
>>> limitation for anyone wanting to work with large amounts of data
>>> (e.g. game maps). Of course I could work around this by calculating
>>> the positions manually using x*width+y, but I'd like to know the
>>> reason why this limitation was put there in the first place, and
>>> what's the reasoning behind it.
>>>
>> just new the array.
>>
> If you mean that I do something like:
> int[4096][4096]* arr = (new int[4096][4096][1]).ptr;
> 1) the compiler still (normally) doesn't let me do it
> 2) it's slower for random access due to having to dereference a
> pointer.
>
> But, yes, this is the sanest workaround so far.
>
I was thinking of this:
alias int[4096] block; // alias to be shure I get dynamic array of static
arrays
block[] arr = new block[4096];
More information about the Digitalmars-d
mailing list