template class Core::MemoryPool

Overview

Helper for lazy memory pool initialization. More…

#include <coremempool.h>

template <class AtomicPolicy>
class MemoryPool
{
public:
    // structs

    struct Bucket;

    // construction

    MemoryPool (uint32 blockSize, uint32 count = 0, CStringPtr name = nullptr);

    // methods

    CStringPtr getName () const;
    bool allocate (uint32 count);
    bool grow (uint32 count);
    void deallocate ();
    void* newBlock ();
    void deleteBlock (void* ptr);
    uint32 getBlockSize () const;
    uint32 getBytesAllocated () const;
    float getBlockUtilization () const;
    bool check () const;
};

Detailed Documentation

Helper for lazy memory pool initialization.

Memory pool template class, needs an outside atomic stack implementation.

Methods

CStringPtr getName () const

Get memory pool name.

bool allocate (uint32 count)

Allocate pool memory blocks.

bool grow (uint32 count)

Grow pool by given number of blocks.

void deallocate ()

Free all memory blocks.

void* newBlock ()

Use a memory block.

void deleteBlock (void* ptr)

Free a memory block.

uint32 getBlockSize () const

Get pool block size.

uint32 getBytesAllocated () const

Get number of bytes allocated.

float getBlockUtilization () const

Get relation between used/free memory blocks (0..1).

bool check () const

Check if memory has been overwritten.