|
| Gator () |
| Please use the init() function to specify parameters, not the constructor. More...
|
|
| Gator (const Gator &)=delete |
| A Gator object may be moved but not copied. More...
|
|
| Gator (Gator &&) |
| A Gator object may be moved but not copied. More...
|
|
| ~Gator () |
| All pools are automatically finalized when a Gator object is destroyed. More...
|
|
void * | allocate (size_t bytes, char const *label="") |
| Allocate the requested number of bytes using the requested label, and return the pointer to allocated space. More...
|
|
void | finalize () |
| Finalize the pool allocator, deallocate all individual pools. More...
|
|
void | free (void *ptr, char const *label="") |
| Free the passed pointer, and return the pointer to allocated space. More...
|
|
void | free_completed_waiting_entries () |
| Check all deallcation entries that are waiting on stream events to see if those events have completed. If the events are completed, then free the entry from the pool. More...
|
|
void | free_with_event_dependencies (void *ptr, std::vector< Event > events_in, char const *label="") |
| Free the passed pointer, and return the pointer to allocated space. More...
|
|
size_t | get_bytes_currently_allocated () const |
| Get the current number of bytes that have been allocated in the pools (this is actual allocation, not pool capacity) More...
|
|
size_t | get_high_water_mark () const |
| Get the current memory high water mark in bytes for all allocations passing through the pool. More...
|
|
size_t | get_num_allocs () const |
| Get the total number of allocations in all of the pools put together. More...
|
|
int | get_num_pools () const |
| Get the current number of pools that have been allocated. More...
|
|
size_t | get_pool_capacity () const |
| Get the total capacity of all of the pools put together. More...
|
|
double | get_pool_high_water_space_efficiency () const |
| Get the proportion of total capacity among pools that has been allocated at this largest past memory usage. More...
|
|
double | get_pool_space_efficiency () const |
| Get the current proportion of total capacity among pools that is actually allocated. More...
|
|
void | init (std::function< void *(size_t)> mymalloc=[](size_t bytes) -> void *{ return ::malloc(bytes);}, std::function< void(void *)> myfree=[](void *ptr) { ::free(ptr);}, std::function< void(void *, size_t)> myzero=[](void *ptr, size_t bytes) {}, size_t initialSize=1024 *1024 *1024, size_t growSize=1024 *1024 *1024, size_t blockSize=16 *sizeof(size_t), std::string pool_name="Gator", std::string error_message_out_of_memory="", std::string error_message_cannot_grow="") |
| Initialize the pool. More...
|
|
Gator & | operator= (const Gator &)=delete |
| A Gator object may be moved but not copied. More...
|
|
Gator & | operator= (Gator &&) |
| A Gator object may be moved but not copied. More...
|
|
void | printAllocsLeft () |
| [USEFUL FOR DEBUGGING] Print all allocations left in this pool object. More...
|
|
YAKL Pool allocator class.
Growable pool allocator for efficient frequent allocations and deallocations. User determines allocation, free, initial pool size, additional pool size, and other pool allocator characteristics upon initiailization.
Once existing pools run out of memory, additional pools are create. Each pool is based on a simple linear search for free slots that is as efficient in memory usage as possible. While search time is linear rather than log in complexity, allocations and frees are typically overlapped with kernel execution.
Gator objects are thread safe for allocate() and free() calls.
void* yakl::Gator::allocate |
( |
size_t |
bytes, |
|
|
char const * |
label = "" |
|
) |
| |
|
inline |
Allocate the requested number of bytes using the requested label, and return the pointer to allocated space.
The pool allocator will search from beginning to end for a slot large enough to fit this allocation request. This minimizes segmentation at the cost of a linear search time. If the current pool(s) do not contain enough room, a new pool is created.
Attempting to allocate zero bytes will return nullptr
. This is a thread safe call.
This always checks to see if entries waiting on stream events are able to be deallocated before allocating.