Sign in to follow this  

Memory Allocator from a specified block of memory.

This topic is 2050 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Take a look at TLSF ([url="http://tlsf.baisoku.org/"]http://tlsf.baisoku.org/[/url]). 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.

Share this post


Link to post
Share on other sites

This topic is 2050 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this