custom memoery manager

hi
I am writing my memory manager.I want to allocate single chunk of memory with different size to 2d dymensional arrays from memory pool.I know how to overload new and delete. But dont know how to creaate and manage memory pool and allocating memory to array. I surf net but most of them overload new with in a class(mostly useful for game developers) and do not have memory pool. can anybody give me some clue or guide me to useful references or show me a simple example to find my way in custom memory allocator?.

Thanks.
||
Last edited on
There are many pool allocators available, from boost and other libraries. Could you describe your idea in more detail?
could you please tell me the name of those pool allocators?(particularly the simple one with less complexity.)

I read in web that boost lib is not so good at least not yet. by the way I want do it my self for my application.

I want to implement my allocator but why?

I am working on performance issues on multicore .so I want to have some experiments on allocator and its Impact on my application behaviour (ofcourse I know it leads to achieving considerable speed in application which request/release memory too much) i.e test locality in memory allocation and thereafter working on separeate pool for each core and working on allocator algorithms(bestfit,ff,...).actually I need to learn and experiment it my self to grasp concepts fully. I know about tcmalloc and hoard I also tested hoard but it takes longer time than original fedora core allocator with g++ 4.7 I contact the author but could not find the reason.

I know about prematured optimization and its impact. Currently I want to allocate any size single contigious chunk of memory to 2d array and after that supporting thread requests for memory(mybe I should overload new globally in my application inorder to let thread request memory from my pool).
I want to start from scratch or mabe reinvent the wheel.But I think I need to experiment it but could not find good reference or tutorial for that I heard of book effective c++ by Scott Meyers but I have no access to that book.



Last edited on
could you please tell me the name of those pool allocators?

Boost has boost::pool_allocator and boost::fast_pool_allocator, see
http://www.boost.org/doc/libs/release/libs/pool/doc/html/index.html but it's such a common task, there are really dozens of pool allocators.

am working on performance issues on multicore

Then perhaps you need Intel's memory_pool_allocator? http://threadingbuildingblocks.org/docs/help/reference/appendices/community_preview_features/scalable_memory_pools/memory_pool_allocator_cls.htm


Currently I want to allocate any size single contigious chunk of memory to 2d array and after that supporting thread requests for memory

That's not enough detail: any allocation gives a contiguous chunk of memory, and all (reasonable) 2D array libraries use single allocations. You said you tested hoard, do you have a compilable test case?
any allocation gives a contiguous chunk of memory


yes for this syntax type name [size][size] but when creating 2d array with pointers then hardly can say all 2d array are in one chunk specially if corun application agressively requst/release memory. cause you have rows/columns of pointer which each points to one column /rows each then there is no garanties to allocate memory in contiguous physical memory location.

do you have a compilable test case?


I used hoard benchmark cache-scractch and others in available benchmark folder and compile it by linking libhord.so to it but the result was as i said I also write my own test but I deleted. you can find my query about hoard problem here https://github.com/emeryberger/Hoard/issues/6

thanks for links ,I also tried googling with "memory pool" I found some example. before that I searched just memory manager or allocator. I dont know why I didnt search this keyword!!!.

Last edited on
rows/columns of pointer which each points to one column /rows each

We aren't talking about the same thing then. I would suggest starting by using a matrix or multi-array library.
so you mean that I use boost multi array lib in my allocator or instead of allocator use multi array or boost pool with multi array.

Last edited on
I mean that arrays of pointers to rows are not 2D arrays to begin with. Changing that with custom allocators is like optimizing bubble sort.
Topic archived. No new replies allowed.