#include <Pt/PageAllocator.h>
Page based allocator. More...
Inherits Allocator, and NonCopyable.
Public Member Functions | |
PageAllocator (std::size_t pageSize=MinChunkSize) | |
Construct with minimum page size. | |
~PageAllocator () | |
Destructor. | |
void * | allocate (std::size_t size) |
Allocates size bytes of memory. | |
void | clear () |
Releases all memory. | |
void | deallocate (void *p, std::size_t size) |
Deallocates memory of size bytes. | |
The PageAllocator is useful, when chunks of memory have to be allocated, that can be released simultaneously. This allows the PageAllocator to allocate memory consecutively on pages and simply release all pages together at the end. Therefore, deallocate() will not do anything, but memory will only eventually be released, when clear() is called or the PageAllocator is destructed. The next example illustrates this: