I've noticed for a long time that games (mostly FPSes) do not unload the map when the user has finished with it (aka, disconnecting from servers, server changing maps).

The result of this is that the maps are kept in memory, which can lead to colossal memory usage in the region of 5GB for a 2 hour session of CoD:Black Ops 2 or around 8GB for a session of the same time of Crysis Wars.

Games most notable for this behaviour (that I've noticed) are the Crysis series and Call of Duty: Black Ops 2.

I've noticed this for years, but now as I am 'upgrading' Crysis Wars (fixing bugs, adding features, and porting it to my new multiplayer network) I have been able to unload maps when the game is done with them. As a result after two hours of playing the memory usage has dropped from an average of 8GB to just 2GB (I jumped between servers a few times when testing this out).

Is keeping maps in memory when the game doesn't need them anymore a bug, or is it purposeful? This 'memory-leak' exists in other Crysis games and also the Call of Duty series (also on consoles, although I'm not certain of this), so it seems to be purposeful rather than a bug.

I've also had a look at what is actually kept around after disconnecting from a server, and it seems that all entities are left behind but the terrain and hightmaps are removed. A similar thing probably happens with CoD:BO2 where I've also observed this.

Obviously I wouldn't want to purge the map from memory if there was a reason behind it, but however I've noticed no adverse effects so far in Crysis Wars.

  • 2
    \$\begingroup\$ A memory leak this big is out of the question. I guess it is a design decision to reduce load times if the user decides to play on the same level again. Why not if the user has unused memory? \$\endgroup\$ – János Turánszki Dec 2 '14 at 22:44

Yes, there's a reason to do this.

The user might want to play the map again, and if so having all (or at least most of) the map already resident in memory means it doesn't needed to be loaded from disk again, thus reducing load times in that (often typical) case.

Purging something from memory is not free, either, as there may be references to loaded that data need to be cleaned up, and so on. At the very least the OS needs to be informed that the relevant pages are now unused, and must update its internal bookkeeping.

Nobody can speak to the specific reasons that specific games choose to keep certain kinds of data resident in memory except the developers who made those decisions. But there are optimizations to be had. Games generally assume they have the user's sole focus and will thus attempt to maximize utilization of the machine while running.

  • 1
    \$\begingroup\$ Maps can have shared recourses so loading the first map might require 2 gigs while the next might only require 1 if the previous data is kept. Keeping that remaining data becomes less costly. Also intense games generally don't expect you to be multitasking in the background so filling extra ram isn't considered bad. \$\endgroup\$ – stas Dec 3 '14 at 2:56
  • \$\begingroup\$ Good point on the shared resources issue. \$\endgroup\$ – user1430 Dec 3 '14 at 2:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.