class MemPager

Accumulative object memory allocator. More...

Definition#include <../common/misc.h>
Inherited bySharedMemPager, Keydata
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Members

Protected Members


Detailed Description

The memory pager is used to allocate cumulative memory pages for storing object specific "persistant" data that is presumed to persist during the life of a given derived object. When the object is destroyed, all accumulated data is automatically purged.

void * first (size_t size)
[protected virtual]

Allocate first workspace from paged memory. This method scans all currently allocated blocks for available space before adding new pages and hence is both slower and more efficient.

Parameters:
sizeof memory to allocate.

Returns: pointer to allocated memory.

void * alloc (size_t size)
[protected virtual]

Allocate memory from either the currently active page, or allocate a new page for the object.

Parameters:
sizeof memory to allocate.

Returns: pointer to allocated memory.

char * first (char *str)
[protected]

Allocate a string from the memory pager pool and copy the string into it's new memory area. This method allocates memory by first searching for an available page, and then allocating a new page if no space is found.

Parameters:
strto allocate and copy into paged memory pool.

Returns: copy of string from allocated memory.

char * alloc (char *str)
[protected]

Allocate a string from the memory pager pool and copy the string inti it's new memory area. This checks only the last active page for available space before allocating a new page.

Parameters:
strto allocate and copy into paged memory pool.

Returns: copy of string from allocated memory.

MemPager (int pagesize = 4096)
[protected]

Create a paged memory pool for cumulative storage. This pool allocates memory in fixed "pagesize" chunks. Ideal performance is achived when the pool size matches the system page size. This pool can only exist in derived objects.

Parameters:
pagesizeto allocate chunks.

void purge (void)
[protected]

purge the current memory pool.

~MemPager ()
[protected virtual]

Delete the memory pool and all allocated memory.

inline int getPages (void)

Return the total number of pages that have been allocated for this memory pool.

Returns: number of pages allocated.