   2d mp game with large tile map
  I am currently working on a 2d multiplayer online game (wouldn't quite say mmo) which has a tile map size of 1024x1024x20. Only a small portion of that area is in use at the moment but could conceivably be even larger at some point (in x/y not z). Everything works fine as it is however the map format is a three dimensional vector of our tile structure. The problem with this is that we have tons of wasted memory due to 'empty' sections of the map. Loading the map currently uses approx 500mb of even though there is only approx 10mb of actual map data. I am looking for possible solutions to this. Is there a way to NULL unused elements during the initial resize of the vector? I have also been looking into using std::map to only load map positions which exist, using a translated coord as the key for each element. Testing this showed very slow initial load time and higher memory usage per element, compared to the same sized vector.   
  What you could do is at the beginning of your map data file, put two numbers. The first is for the max X value, and the second is for the max Y value. Then before you make the vector for the map and such, just load those numbers and use them for the max X and Y values of the map. That way you never use anymore memory than you need to.If I read your problem correctly, that should fix the memory issue your having...   ;  I should elaborate a bit I suppose. The map isn't evenly filled, there are gaps where players cannot see, or even large chunk's under or over a players current position that are unused. The normal area the player would spawn (the 'surface') would be z=10, levels 0-9 are 'above' the ground. this creates huge areas of the map that are unused, this also happens underground where there are dungeons, tunnels, etc. Ive included this ss of the map. This is currently at level 9 (1 floor above the 'ground'). You can see all the shaded NT tiles, those are empty structs in the vector (note, there is no actual 'NT' tile in that position, the editor puts them there so i can see it's an empty space :)). http://yfrog.com/31mapvqp   ;  What about streaming?You could load / discard stuff as you go just don't use a std::vector for that.A regular array should be sufficient with enough pitch to make disk reads a bit more contentful.With a nice caching scheme, the thing should not even trash too much, as the player likely has limited movement speed.Loading everything and anything is a bit simplistic approach in this case.Edit:Which works on client side....On the server side though....Some sort of graph representation of the world perhaps?Each node would potentially have 4 + 1 or 2 neighbors.That way you could only allocate those nodes that have anything meaningful in them.