I'm very new to C++ so I'm somewhat confused about how static arrays work. I know in C# the array isn't placed into memory until it's first accessed which can be problematic if you want it to be instantly accessible. However, I'm working on converting a Perlin class to C++ and I'd like to have multiple static arrays of which only one may be used during runtime or any number of them. In reality, it's not really that big of a memory issue as none of them will be more than 50kb, however, I'd rather know if it's possible to ensure the array isn't loaded into memory unless I ask for it. Is there a way to ensure a static array defined in source code isn't loaded into memory unless asked for? It's a pretty nitpicky thing (esp w/ x64), but I'd prefer to be as optimized about it as possible. I hate the idea of taking up memory with something that isn't going to be used.
Or maybe static arrays aren't even the way to go - just dynamical class object wrapped arrays?
I guess the real question is: what is the most efficient solution for implementing table-lookups in c++ that might not all be used?
constarrays (with any sub-objectsconst) then they can live in the code area , i.e. they won't require any extra allocation of memory. The code area of the executable will be mapped into the process's virtual address space and things can be read directly out of it.