Resource Tuner
Loading...
Searching...
No Matches
MemoryPool Class Reference

MemoryPool. More...

#include <MemoryPool.h>

Public Member Functions

int32_t makeAllocation (int32_t blockCount)
 Allocate memory for the specified type T.
 
void * getBlock ()
 Get an allocated block for the already allocated type T.
 
void freeBlock (void *block)
 Free an allocated block of the specified type T.
 

Detailed Description

MemoryPool.

Preallocate Memory for Commonly Used types, to decrease the Runtime Overhead of Memory Allocation and Deallocation System Calls while Processing Requests.

Definition at line 53 of file MemoryPool.h.

Member Function Documentation

◆ freeBlock()

void MemoryPool::freeBlock ( void *  block)

Free an allocated block of the specified type T.

Parameters
blockPointer to the block to be freed.

◆ getBlock()

void * MemoryPool::getBlock ( )

Get an allocated block for the already allocated type T.

This routine should only be called after the makeAllocation call for a particular type Note: If a block is not available then the Routine throws a std::bad_alloc exception.

Returns
void*:
  • Pointer to the allocated type.

◆ makeAllocation()

int32_t MemoryPool::makeAllocation ( int32_t  blockCount)

Allocate memory for the specified type T.

This routine will allocate the number of memory blocks for the type specified by the client.

Parameters
blockCountNumber of blocks to be allocated.
Returns
int32_t:
  • Number of blocks which were actually allocated (might be smaller than blockCount)

The documentation for this class was generated from the following file: