16MB static arrays again...

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Wed Aug 24 11:16:01 PDT 2016


On 8/24/2016 3:35 AM, Tomer Filiba wrote:
> On Wednesday, 24 August 2016 at 09:38:43 UTC, Walter Bright wrote:
>>> 2) Many times I need memory-contiguity, e.g., several big arrays inside a
>>> struct, which is dumped to disk/sent over network. I can't use pointers there.
>>
>> I don't know why pointers cannot be used. Can you show the struct definition
>> you're using?
>
> Our configuration is a struct of several static hash tables (allocated in-place,
> not via GC). So the entire configuration is contiguous is memory, which allows
> us to dump/load/send it easily.
>
> When we increase the capacity of these tables we run into these pain-in-the-ass
> 16MB limits. So although the struct itself is over 16MB, no single table can
> cross several thousand entries, as the static arrays it uses internally would
> overflow that boundary.
>
> The configuration itself may very well be dynamically allocated (e.g., not a
> global variable) but that won't solve anything as the restriction is on the
> *type* of the array.


If I understand you correctly, removing the size limitation on the type will 
resolve the issue for you? Even though allocating static data of such a size 
will still not be allowed?

BTW, given globals in C++:

    int a[100];
    float b[200];
    long c;

there actually is no guarantee that they are allocated contiguously, and indeed 
I've run into bugs in my code because I had relied on that. They'd have to be 
put into a struct to get a guarantee.


More information about the Digitalmars-d mailing list