How do games like GTA IV not fragment the heap?

后端 未结 6 1254
深忆病人
深忆病人 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:00

    Creating and destroying lots of objects really quickly doesn't necessarily mean heap fragmentation. Often, if the objects are of the same size, then the space freed by one can be allocated for the next.

    Often, even just as an optimization, a program might not free and delete memory for objects, but keep old ones in a pool and simply grab one and overwrite the contents to create a 'new' object.

提交回复
热议问题