16MB static arrays again...
Tomer Filiba via Digitalmars-d
digitalmars-d at puremagic.com
Thu Aug 25 10:32:28 PDT 2016
On Wednesday, 24 August 2016 at 18:16:01 UTC, Walter Bright wrote:
> On 8/24/2016 3:35 AM, Tomer Filiba wrote:
...
>> Our configuration is a struct of several static hash tables
>> (allocated in-place, not via GC). So the entire configuration
>> is contiguous in memory
...
> 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?
(1) Why won't allocating such static data be allowed? Gold has no
such limitations
(2) Why do linker limitations have to do with the inner working
on types?
(3) I may very well allocate the entire config using malloc, or
on the stack (given a huge stack). The linker has nothing to do
with it
> BTW, given globals in C++:
>
> int a[100];
> float b[200];
> long c;
>
> there actually is no guarantee that they are allocated
> contiguously, ... They'd have to be put into a struct to get a
> guarantee.
As I said (quoted above), the configuration is a struct. It looks
like
struct Config {
Table!(K1, V1, 10000) myTable;
Table!(K2, V2, 10000) yourTable;
Table!(K3, V3, 10000) hisTable;
Table!(K4, V4, 10000) herTable;
}
So it is surely contiguous.
Table is a static hash table built on top of a static array,
since it has a known capacity. When `V1.sizeof * 10_000 > 16MB`,
it fails to compile
Btw, I set declare everything with `field = void` to prevent the
struct from having a huge init symbol. I take care of
initialization in runtime.
-tomer
More information about the Digitalmars-d
mailing list