Array memory management

I am engaged in my project "Computer Science". I am doing multi-processor programming using C. One requirement for us is that we cannot continue to allocate small chunks of memory. If necessary, memory can be allocated in large chunks.

So, imagine that I use structures in my program. And the way my program works requires dynamic memory allocation. But this is a very expensive equipment that we use. Thus, the best solution would be to allocate a large memory pool at the beginning and whenever it is necessary to allocate memory from this pool.

As I assume this works, I allocated a bit of an array of these structures and write my own memory management module that allocates and frees memory from this pool. But I want to know the most ideal way to write these modules. Are there libraries that can help me manage memory, or is there a way that they can be written?

EDIT: here is the platform I'm using: AMD opteron, which runs Ubuntu. Opterons have a NUMA architecture, and I want to use this when allocating memory. Therefore, instead of using malloc, I use numa_alloc_onnode , which allocates memory on one particular node. I want to allocate a large chunk of memory using this and then using the memory manager to manage this memory.

+1
source share
1 answer

There are tons of memory pool managers, some commercial and some open source. Look at them and feel free to ask more specific questions here when you have a review.

Some google results (open source memory pool):

http://256stuff.com/sources/mpool/

http://www.ravenbrook.com/project/mps/

Here is a good IBM related article:

http://www.ibm.com/developerworks/linux/library/l-memory/

And since you mention a multiprocessor environment (albeit not directly related to memory management), it is also useful to read:

http://drdobbs.com/go-parallel/article/showArticle.jhtml?articleID=217500206

UPDATE

. , malloc ( calloc), , ( , ). , , , .

, , . , :

  • , , .
  • (, , , )
  • (, , ).
  • (, ).

2

... . NUMA ( ):

http://ebookbrowse.com/numa-aware-heap-memory-manager-article-final-pdf-d12526838

+4

All Articles