1 Feb 2005 01:35
Re: Addressing fragmentation
Paul Du Bois <paul.dubois <at> gmail.com>
2005-02-01 00:35:46 GMT
2005-02-01 00:35:46 GMT
On Tue, 1 Feb 2005 10:26:10 +1100, Mark Wayland <Mwayland <at> torus.com.au> wrote: > (1) Pools of fixed sized items; simple, exceedingly fast and only 4 > bytes overhead for the entire pool, not on each item. > (2 lines of code for an allocate, 2 lines for free, memory required = > 4 + (pool item count * pool item size)) This brings up something I've wondered about recently. I require that users of the pool system track allocation sizes themselves, and pass it to (our version of) free(); with so many ways of allocating memory, it's hard to tell just from a bare pointer (or even a pointer and a library id) where the pointer came from. I especially don't want to go through all our various pools asking them "did this pointer come from you?" An additional C++ annoyance is that there doesn't seem to be a way to pass arguments to the delete operator and have them passed onto operator delete. So while it's easy to do something like char* pFoo = new(arena) char[n]; you can't follow it up with delete(arena)[] pFoo; So instead we either macro in operators new/delete into the class declaration, or use a more verbose API. Any clever tricks here? p(Continue reading)
p
_______________________________________________
Sweng-gamedev mailing list
Sweng-gamedev <at> lists.midnightryder.com
.
RSS Feed