
- Forum
- Programming Talk
- C and C++
- How to Carry out Implementation
How to Carry out Implementation
This is a discussion on How to Carry out Implementation within the C and C++ forums, part of the Programming Talk category; I want to know how one can carry out Memory pool implementation using C++ programming language. Also let me know ...
-
How to Carry out Implementation
I want to know how one can carry out Memory pool implementation using C++ programming language. Also let me know how to access the allocated memory pool using C++ programming language. If someone idea is provided in this line I would try the same and envisage my knowledge in this regard.
-
You can use the following statement to allocate memory
MemPoolHandle allocateMemory(size_t bytes);
If you are creating a simple memory pool it would surely allocate three pools during compile time and the block size allocated for each depends on the application.
-
02-22-2012, 06:28 AM #3
- Join Date
- Feb 2012
- Answers
- 66
A simple memory pool module can allocate, for example, 3 pools at compile time with block sizes optimized for the application which depends on the module. The application can allocate, access and free memory with the following interface:
> Allocate memory from the pools. The function will determine the pool where the required block fits in. If all blocks of that pool are already reserved, the function tries to find one in the next bigger pool(s). An allocated memory block is represented with a handle.
> The handle can for example be implemented with an unsigned int. The module can interpret the handle internally by dividing it into pool index, memory block index and a version. The pool and memory block index allow fast access, while the version, is incremented at each new allocation.
>Get an access pointer to the allocated memory.
> Free the formerly allocated memory block.
-
Sponsored Ads

Reply With Quote





