Skip to main content
GameDev.net gamedev.net
🔒 Locked

Memory Allocator from a specified block of memory.

Started by bluntman May 5, 2012 at 6:53 PM 0 replies 2k views
Original Post
bluntman
bluntman
Does anybody know of a good allocator that can use a specified block of memory as its pool? All the ones I can find seem to simply work on global pools or internally managed pools. I just want to give the allocator a big contiguous block of memory along with the size and have it return memory allocated from within that. Alternatively (although it is functionally the same) give it a pool size only have have it return blocks from the pool as offsets into it. I guess you could call it an abstract or virtual allocator...

Even better would be an entire system that will manage pointers into a block, where the block can be specified by me, which would include an allocator, and a pointer wrapper that deferences the allocated object from the specified block.
This (incase you haven't guessed) is to allow me to share memory between processes, and dynamically create and allocate objects into it.
osmanb
osmanb
Take a look at TLSF (http://tlsf.baisoku.org/). We use this internally as our primary general-purpose allocator (and I know several other game companies do as well). That version is actually written by a co-worker, and is essentially the same code that we use internally on all of our projects. In addition to TLSF having great algorithmic behavior, that implementation/interface is also pretty simple and clean - in particular you just supply it a pointer and size to create a heap from a block of memory.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.