|
CookMem 1.4.0
A C++ memory context / allocator
|
#include <arena.h>
Public Types | |
| typedef TreeType | PtrTreeType |
Public Member Functions | |
| CachedArena (Arena &arena) | |
| ~CachedArena () | |
| CachedArena (const CachedArena &)=delete | |
| CachedArena & | operator= (const CachedArena &)=delete |
| void * | getSegment (std::size_t &size) |
| bool | freeSegment (void *ptr, std::size_t size) |
| void | releaseAll () |
CachedArena is used to cache the segments released and see if they can be reused in the future segment request.
This class implements the interface of MemArena without explicitly inheriting from it. This is to avoid the overhead of virtual function calls and allows inlining of the functions.
| Arena | the memory arena that does the actual memory allocation |
| TreeType | The type of the tree used to cache the released segments. The default is PtrRBTree. |
| typedef TreeType cookmem::CachedArena< Arena, TreeType >::PtrTreeType |
The type of the tree used to cache the released segments.
|
inline |
Constructor
| arena | the memory arena that does the actual memory allocation |
|
inline |
Destructor. The cached segments are returned to the underlying arena.
|
inline |
Free an arena segment.
The segment release is cached for the next get attempt that can be satisfied.
| ptr | the pointer to be freed. |
| size | the size of the pointer. |
|
inline |
Allocate an arena segment.
It first checks if there is a cached segment that could satisfy the request. If not, it calls the actual memory arena to allocate the segment.
| [in,out] | size | the size of the page. This value is updated upon successful request to indicate the actual size obtained. |
|
inline |
Return all the cached segments to the underlying arena. Segments that a memory pool is still using are not affected.