c++ saving object allocation and deletion -


i'm working on little game, , need somes class/struct allocated , deleted often. i'm wondering way save deletion, maybe putting delete object in container, , try pick in container when want allocate instance of class.

i'm thinkin overload of new , delete operator. have little problem, if overload delete operator (to put "deleted" object in container), how delete it? should pass throught proper function that?

there 2 ways go that

1) pool of objects. when "allocate" take object pool , when deallocate return pool. not transparent implementation not hard.

2) create custom allocator classes/structs. preallocate memory in big buffer , when need allocate take memory there , when need deallocate return memory (the actual mechanism you). bit harder implement can more transparent.

check following links ideas

also, while @ it, there great book alexandrescu

http://www.amazon.com/modern-design-generic-programming-patterns/dp/0201704315

a bit old, exceptional nevertheless , has section memory management/allocator.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -