|
| | allocator () |
| | Default constructor, use mem_key_std. More...
|
| |
| | allocator (PSI_memory_key key) |
| | Explicit constructor. More...
|
| |
| | allocator (const allocator< T, Allocator_base > &)=default |
| |
| allocator< T, Allocator_base > & | operator= (const allocator< T, Allocator_base > &)=default |
| |
| | allocator (allocator< T, Allocator_base > &&)=default |
| |
| allocator< T, Allocator_base > & | operator= (allocator< T, Allocator_base > &&)=default |
| |
| | ~allocator ()=default |
| |
| template<typename U > |
| | allocator (const allocator< U, Allocator_base > &other) |
| | Copy-construct a new instance of allocator with type T by using existing instance of allocator constructed with a different type U. More...
|
| |
| bool | operator== (const ut::allocator< T, Allocator_base > &) const |
| | Equality of allocators instantiated with same types T. More...
|
| |
| bool | operator!= (const ut::allocator< T, Allocator_base > &other) const |
| | Non-equality of allocators instantiated with same types T. More...
|
| |
| size_type | max_size () const |
| | Return the maximum number of objects that can be allocated by this allocator. More...
|
| |
| pointer | allocate (size_type n_elements, const_pointer hint=nullptr) |
| | Allocates chunk of memory that can hold n_elements objects of type T. More...
|
| |
| void | deallocate (pointer ptr, size_type n_elements=0) |
| | Releases the memory allocated through ut::allocator<T>::allocate(). More...
|
| |
template<typename
T, typename Allocator_base = std::conditional_t< ut::WITH_PFS_MEMORY, detail::allocator_base_pfs<T>, detail::allocator_base<T>>>
class ut::allocator< T, Allocator_base >
Allocator that allows std containers to manage their memory through ut::malloc* and ut::free library functions.
Main purpose of this custom allocator is to instrument all of the memory allocations and deallocations that are being done by std containers under the hood, and have them recorded through the PFS (memory) engine.
Other than std containers, this allocator is of course also suitable for use in any other allocator-aware containers and/or code.
Given that ut::malloc* and ut::free library functions already handle all the PFS and non-PFS implementation bits and pieces, this allocator is a mere wrapper around them.
Example which uses default PFS key (mem_key_std) to trace all std::vector allocations and deallocations: std::vector<int, ut::allocator<int>> vec; vec.push_back(...); ... vec.push_back(...);
Example which uses user-provided PFS key to trace std::vector allocations and deallocations: ut::allocator<int> allocator(some_other_psi_key); std::vector<int, ut::allocator<int>> vec(allocator); vec.push_back(...); ... vec.push_back(...);