I am currently developing a 2d mmorpg and am having some memory issues with regards to my tile based map. The client takes a little while to load and then sits around 1GB ram, because I am loading each tile, for each layer, into memory. My map is currently 1/3 of its expected size.
My map has multiple layers which are drawn on top of each other - ground, building, and object. Each of these layers is stored in a separate short array. My question is how can I do this better.
I have thought of some ideas:
- Load zones into memory (i.e. 500x500) and when user goes into next zone disgard and load new 500x500
- Load zones into memory (i.e. 500x500) and when user goes 250 tiles east disgard 0-250 tiles
- Read from filesystem rather than memory
Can anyone give some suggestions and perspectives as to why, which above (or other ideas) work best?
Somes notes/issues I've found:
- My game has 1 seamless world map(hard to split to zones)
- Users can be teleported by GM/DEVs - but will usually only happen if they are stuck somewhere(potiential issues for storing chunks in memory)
- My game is www.KisnardOnline.com for anyone interested.
Thanks anyone/everyone for taking a look and your help.