Why 16Mib static array size limit?

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Wed Aug 17 23:34:01 PDT 2016


On 8/17/2016 9:16 PM, Chris Wright wrote:
> So it's not surprising that the compiler doesn't handle global variables
> as well as it does local ones.

Global variables are pretty much spawn of the devil. You're right that dmd does 
not make a special effort optimizing them.

The way to deal with it:

1. minimize use of globals

2. if using them in a hot loop, copy a reference to the global into a local 
variable, and use the local variable in the loop instead.

This also gets around the problem that thread local storage address calculation 
is slow and inefficient on all platforms.



More information about the Digitalmars-d mailing list