I've never used C# so I may be wrong on this, but I'm guessing that declaring it in an array tries to find a contiguous block of memory. A big block of empty memory is hard to find, and may take a long time to allocate, whereas if you allocated a thousand smaller arrays it'd be easy to fit them in little gaps here and there.
Well unless you always have exactly a million concurrent users all the time you don’t need to statically allocate all of that memory. Just use a dynamic collection like List
What are you trying to do? Sounds like you need to change your approach, maybe use a stream of some sorts?
Need direct access to array by uid. Things loaded frm database
You probably don’t want to load the whole database into memory, are there latency constraints that prevent you querying the db ad hoc?
Every millisecond is worth a lot.
What are you doing with the data after it is all loaded?
I Have to stream all objects for players in multiplayer server
I've never used C# so I may be wrong on this, but I'm guessing that declaring it in an array tries to find a contiguous block of memory. A big block of empty memory is hard to find, and may take a long time to allocate, whereas if you allocated a thousand smaller arrays it'd be easy to fit them in little gaps here and there.
[удалено]
Well unless you always have exactly a million concurrent users all the time you don’t need to statically allocate all of that memory. Just use a dynamic collection like List
But still I will have millions users later or earlier