|
libhatchet
|
#include <hxmemory_manager.h>
Public Member Functions | |
| hxsystem_allocator_scope (hxsystem_allocator_t allocator_) hxattr_noexcept | |
| ~hxsystem_allocator_scope (void) hxattr_noexcept | |
| hxattr_nodiscard size_t | get_current_allocation_count (void) const |
| hxattr_nodiscard size_t | get_current_bytes_allocated (void) const |
| hxattr_nodiscard size_t | get_initial_allocation_count (void) const |
| hxattr_nodiscard size_t | get_initial_bytes_allocated (void) const |
Friends | |
| hxinline void | hxsystem_allocator_scope_init_ (hxsystem_allocator_scope *scope_, size_t allocation_count_, size_t bytes_allocated_) |
hxsystem_allocator_scope - An RAII class to set the current memory manager allocator for the current scope.
It automatically restores the previous allocator when the scope ends. It also resets stack allocators to their initial offsets thereby freeing any allocations made during the lifetime of this object. WARNING: Two threads cannot share a stack allocator using this mechanism without due caution. Wait for worker tasks to complete before freeing their temporary allocations. The closest thing in the standard is std::scoped_allocator_adaptor and it is a template nightmare.
| hxsystem_allocator_scope::hxsystem_allocator_scope | ( | hxsystem_allocator_t | allocator_ | ) |
Constructor: Sets the current memory allocator to the specified ID.
| hxsystem_allocator_scope::~hxsystem_allocator_scope | ( | void | ) |
Destructor restores the stored previous memory manager allocator ID.
May modify current allocator in a way that cannot be shared between threads.
| hxattr_nodiscard size_t hxsystem_allocator_scope::get_current_allocation_count | ( | void | ) | const |
Gets the total number of allocations outstanding for this memory allocator.
There should be no system overhead. Allocations made directly to new, delete, malloc and free are not tracked by hxsystem_allocator_heap.
| hxattr_nodiscard size_t hxsystem_allocator_scope::get_current_bytes_allocated | ( | void | ) | const |
Gets the total number of bytes allocated outstanding for this memory allocator.
Freed bytes might not be reused until the scope closes. There may also be significant system overhead that is not being reported.
|
inline |
Gets the number of allocations made when this scope was entered.
|
inline |
Gets the number of bytes allocated when this scope was entered.
|
friend |