How do games like GTA IV not fragment the heap?

后端 未结 6 1241
深忆病人
深忆病人 2021-01-31 05:21

I\'m interested in the type of memory management a game like GTA IV might use given that it needs to create and delete lots of objects very quickly. How do the avoid fragmenting

6条回答
  •  盖世英雄少女心
    2021-01-31 06:06

    Lots of games use some of the memory allocators mentioned here. dlmalloc is one that we have used with great success (we have tied it into Lua). You can get information on dlmalloc here.

    One other thing that I would mention though, is that not all games have to use dynamic memory allocation. We have employed mempools and use of static memory regions for most of our gameplay data. Only the systems that require dynamic allocation do so (Lua and some third party libraries). Everything else that we do comes out of static buffers. We use no STL in gamecode either, which helps limit the "damage" of memory fragmentation.

提交回复
热议问题