"The total size of a static array cannot exceed 16Mb."

Vladimir Panteleev thecybershadow at gmail.com
Tue Oct 2 00:23:04 PDT 2007


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.

-- 
Best regards,
 Vladimir                          mailto:thecybershadow at gmail.com



More information about the Digitalmars-d mailing list