memory
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
foonathan::memory Namespace Reference

Namespaces

 literals
 

Classes

class  aligned_allocator
 A RawAllocator adapter that ensures a minimum alignment. More...
 
struct  allocate_shared_node_size
 The node size required by allocate_shared. More...
 
class  allocator_adapter
 An alias template for allocator_storage using the direct_storage policy without a mutex. More...
 
class  allocator_deallocator
 A deleter class that deallocates the memory through a specified RawAllocator. More...
 
class  allocator_deallocator< Type[], RawAllocator >
 Specialization of allocator_deallocator for array types. More...
 
class  allocator_deleter
 Similar to allocator_deallocator but calls the destructors of the object. More...
 
class  allocator_deleter< Type[], RawAllocator >
 Specialization of allocator_deleter for array types. More...
 
struct  allocator_info
 Contains information about an allocator. More...
 
struct  allocator_is_raw_allocator
 Traits class that checks whether or not a standard Allocator can be used as RawAllocator. More...
 
struct  allocator_is_raw_allocator< std::allocator< T > >
 Specialization of allocator_is_raw_allocator that allows std::allocator again. More...
 
class  allocator_polymorphic_deallocator
 A deleter class that deallocates the memory of a derived type through a specified RawAllocator. More...
 
class  allocator_polymorphic_deleter
 Similar to allocator_polymorphic_deallocator but calls the destructors of the object. More...
 
class  allocator_reference
 An alias template for allocator_storage using the reference_storage policy. More...
 
class  allocator_storage
 A RawAllocator that stores another allocator. More...
 
class  allocator_traits
 The default specialization of the allocator_traits for a RawAllocator. More...
 
class  allocator_traits< iteration_allocator< N, BlockAllocator > >
 Specialization of the allocator_traits for iteration_allocator. More...
 
class  allocator_traits< memory_pool< PoolType, ImplRawAllocator > >
 Specialization of the allocator_traits for memory_pool classes. More...
 
class  allocator_traits< memory_pool_collection< Pool, BucketDist, RawAllocator > >
 Specialization of the allocator_traits for memory_pool_collection classes. More...
 
class  allocator_traits< memory_stack< BlockAllocator > >
 Specialization of the allocator_traits for memory_stack classes. More...
 
class  allocator_traits< temporary_allocator >
 Specialization of the allocator_traits for temporary_allocator classes. More...
 
struct  any_allocator
 Tag type that enables type-erasure in reference_storage. More...
 
class  any_std_allocator
 An alias template for std_allocator using a type-erased RawAllocator. More...
 
struct  array_pool
 Tag type defining a memory pool optimized for arrays. More...
 
class  bad_alignment
 The exception class thrown when the alignment exceeds the supported maximum, i.e. More...
 
class  bad_allocation_size
 The exception class thrown when an allocation size is bigger than the supported maximum. More...
 
class  bad_array_size
 The exception class thrown when the array size exceeds the supported maximum, i.e. More...
 
class  bad_node_size
 The exception class thrown when the node size exceeds the supported maximum, i.e. More...
 
class  binary_segregator
 A RawAllocator that either uses the Segregatable or the other RawAllocator. More...
 
class  bucket_allocator
 An alias for memory_pool_collection using the identity_buckets policy and a PoolType defaulting to node_pool. More...
 
class  composable_allocator_traits
 The default specialization of the composable_allocator_traits for a ComposableAllocator. More...
 
class  composable_allocator_traits< iteration_allocator< N, BlockAllocator > >
 Specialization of the composable_allocator_traits for iteration_allocator classes. More...
 
class  composable_allocator_traits< memory_pool< PoolType, BlockOrRawAllocator > >
 Specialization of the composable_allocator_traits for memory_pool classes. More...
 
class  composable_allocator_traits< memory_pool_collection< Pool, BucketDist, RawAllocator > >
 Specialization of the composable_allocator_traits for memory_pool_collection classes. More...
 
class  composable_allocator_traits< memory_stack< BlockAllocator > >
 Specialization of the composable_allocator_traits for memory_stack classes. More...
 
class  deeply_tracked_allocator
 A tracked_allocator that has rebound any BlockAllocator to the corresponding deeply_tracked_block_allocator. More...
 
class  deque
 Alias template for an STL container that uses a certain RawAllocator. More...
 
class  deque_scoped_alloc
 Same as above but uses std::scoped_allocator_adaptor so the allocator is inherited by all nested containers. More...
 
class  direct_storage
 A StoragePolicy that stores the allocator directly. More...
 
class  double_frame_allocator
 An alias for iteration_allocator for two iterations. More...
 
class  fallback_allocator
 A RawAllocator with a fallback. More...
 
class  fixed_block_allocator
 A BlockAllocator that allows only one block allocation. More...
 
class  forward_list
 Alias template for an STL container that uses a certain RawAllocator. More...
 
struct  forward_list_node_size
 Contains the node size of a node based STL container with a specific type. More...
 
class  forward_list_scoped_alloc
 Same as above but uses std::scoped_allocator_adaptor so the allocator is inherited by all nested containers. More...
 
class  growing_block_allocator
 A BlockAllocator that uses a given RawAllocator for allocating the blocks. More...
 
struct  identity_buckets
 A BucketDistribution for memory_pool_collection defining that there is a bucket, i.e. More...
 
struct  is_block_allocator
 Traits that check whether a type models concept BlockAllocator. More...
 
struct  is_composable_allocator
 Traits that check whether a type models concept ComposableAllocator. More...
 
struct  is_raw_allocator
 Traits that check whether a type models concept RawAllocator. More...
 
struct  is_shared_allocator
 Specifies whether or not a RawAllocator has shared semantics. More...
 
struct  is_shared_allocator< joint_allocator >
 Specialization of is_shared_allocator to mark joint_allocator as shared. More...
 
struct  is_shared_allocator< memory_resource_allocator >
 Specialization of is_shared_allocator to mark memory_resource_allocator as shared. More...
 
struct  is_thread_safe_allocator
 Specifies whether or not a RawAllocator is thread safe as-is. More...
 
struct  is_thread_safe_allocator< joint_allocator >
 Specialization of is_thread_safe_allocator to mark joint_allocator as thread safe. More...
 
class  iteration_allocator
 A stateful RawAllocator that is designed for allocations in a loop. More...
 
class  joint
 Tag type that can't be created. More...
 
class  joint_allocator
 A RawAllocator that uses the additional joint memory for its allocation. More...
 
class  joint_array
 A zero overhead dynamic array using joint memory. More...
 
class  joint_ptr
 A pointer to an object where all allocations are joint. More...
 
struct  joint_size
 Tag type to make the joint size more explicit. More...
 
class  joint_type
 CRTP base class for all objects that want to use joint memory. More...
 
class  list
 Alias template for an STL container that uses a certain RawAllocator. More...
 
struct  list_node_size
 Contains the node size of a node based STL container with a specific type. More...
 
class  list_scoped_alloc
 Same as above but uses std::scoped_allocator_adaptor so the allocator is inherited by all nested containers. More...
 
struct  log2_buckets
 A BucketDistribution for memory_pool_collection defining that there is a bucket, i.e. More...
 
class  map
 Alias template for an STL container that uses a certain RawAllocator. More...
 
struct  map_node_size
 Contains the node size of a node based STL container with a specific type. More...
 
class  map_scoped_alloc
 Same as above but uses std::scoped_allocator_adaptor so the allocator is inherited by all nested containers. More...
 
class  memory_arena
 A memory arena that manages huge memory blocks for a higher-level allocator. More...
 
struct  memory_block
 A memory block. More...
 
class  memory_pool
 A stateful RawAllocator that manages nodes of fixed size. More...
 
class  memory_pool_collection
 A stateful RawAllocator that behaves as a collection of multiple memory_pool objects. More...
 
class  memory_resource
 The memory_resource abstract base class used in the implementation. More...
 
class  memory_resource_adapter
 Wraps a RawAllocator and makes it a memory_resource. More...
 
class  memory_resource_allocator
 Wraps a memory_resource and makes it a RawAllocator. More...
 
class  memory_stack
 A stateful RawAllocator that provides stack-like (LIFO) allocations. More...
 
class  memory_stack_raii_unwind
 Simple utility that automatically unwinds a Stack to a previously saved location. More...
 
class  multimap
 Alias template for an STL container that uses a certain RawAllocator. More...
 
struct  multimap_node_size
 Contains the node size of a node based STL container with a specific type. More...
 
class  multimap_scoped_alloc
 Same as above but uses std::scoped_allocator_adaptor so the allocator is inherited by all nested containers. More...
 
class  multiset
 Alias template for an STL container that uses a certain RawAllocator. More...
 
struct  multiset_node_size
 Contains the node size of a node based STL container with a specific type. More...
 
class  multiset_scoped_alloc
 Same as above but uses std::scoped_allocator_adaptor so the allocator is inherited by all nested containers. More...
 
struct  no_mutex
 A dummy Mutex class that does not lock anything. More...
 
struct  node_pool
 Tag type defining a memory pool optimized for nodes. More...
 
class  null_allocator
 A composable RawAllocator that will always fail. More...
 
class  out_of_fixed_memory
 A special case of out_of_memory errors thrown when a low-level allocator with a fixed size runs out of memory. More...
 
class  out_of_memory
 The exception class thrown when a low level allocator runs out of memory. More...
 
class  priority_queue
 Alias template for an STL container that uses a certain RawAllocator. More...
 
class  priority_queue_scoped_alloc
 Same as above but uses std::scoped_allocator_adaptor so the allocator is inherited by all nested containers. More...
 
struct  propagation_traits
 Controls the propagation of a std_allocator for a certain RawAllocator. More...
 
struct  propagation_traits< joint_allocator >
 Specialization of the propagation_traits for the joint_allocator. More...
 
class  queue
 Alias template for an STL container that uses a certain RawAllocator. More...
 
class  queue_scoped_alloc
 Same as above but uses std::scoped_allocator_adaptor so the allocator is inherited by all nested containers. More...
 
class  reference_storage
 A StoragePolicy that stores a reference to an allocator. More...
 
class  reference_storage< any_allocator >
 Specialization of the class template reference_storage that is type-erased. More...
 
class  segregator
 Creates multiple nested binary_segregator. More...
 
struct  segregator_size
 The number of Segregatable a segregator has. More...
 
class  set
 Alias template for an STL container that uses a certain RawAllocator. More...
 
struct  set_node_size
 Contains the node size of a node based STL container with a specific type. More...
 
class  set_scoped_alloc
 Same as above but uses std::scoped_allocator_adaptor so the allocator is inherited by all nested containers. More...
 
struct  shared_ptr_node_size
 Contains the node size of a node based STL container with a specific type. More...
 
struct  small_node_pool
 Tag type defining a memory pool optimized for small nodes. More...
 
class  stack
 Alias template for an STL container that uses a certain RawAllocator. More...
 
class  stack_scoped_alloc
 Same as above but uses std::scoped_allocator_adaptor so the allocator is inherited by all nested containers. More...
 
class  static_allocator
 A stateful RawAllocator that uses a fixed sized storage for the allocations. More...
 
struct  static_allocator_storage
 Storage for a static_allocator. More...
 
class  static_block_allocator
 A BlockAllocator that allocates the blocks from a fixed size storage. More...
 
class  std_allocator
 Wraps a RawAllocator and makes it a "normal" Allocator. More...
 
class  string
 Alias template for an STL container that uses a certain RawAllocator. More...
 
class  temporary_allocator
 A stateful RawAllocator that handles temporary allocations. More...
 
class  temporary_stack
 A wrapper around the memory_stack that is used by the temporary_allocator. More...
 
class  temporary_stack_initializer
 Manually takes care of the lifetime of the per-thread temporary_stack. More...
 
class  thread_safe_allocator
 An alias template for allocator_storage using the direct_storage policy with a mutex. More...
 
class  threshold_segregatable
 A Segregatable that allocates until a maximum size. More...
 
class  tracked_allocator
 A RawAllocator adapter that tracks another allocator using a tracker. More...
 
class  tracked_block_allocator
 A BlockAllocator adapter that tracks another allocator using a tracker. More...
 
class  unique_base_ptr
 A std::unique_ptr that deletes using a RawAllocator and allows polymorphic types. More...
 
class  unique_ptr
 A std::unique_ptr that deletes using a RawAllocator. More...
 
class  unordered_map
 Alias template for an STL container that uses a certain RawAllocator. More...
 
struct  unordered_map_node_size
 Contains the node size of a node based STL container with a specific type. More...
 
class  unordered_map_scoped_alloc
 Same as above but uses std::scoped_allocator_adaptor so the allocator is inherited by all nested containers. More...
 
class  unordered_multimap
 Alias template for an STL container that uses a certain RawAllocator. More...
 
struct  unordered_multimap_node_size
 Contains the node size of a node based STL container with a specific type. More...
 
class  unordered_multimap_scoped_alloc
 Same as above but uses std::scoped_allocator_adaptor so the allocator is inherited by all nested containers. More...
 
class  unordered_multiset
 Alias template for an STL container that uses a certain RawAllocator. More...
 
struct  unordered_multiset_node_size
 Contains the node size of a node based STL container with a specific type. More...
 
class  unordered_multiset_scoped_alloc
 Same as above but uses std::scoped_allocator_adaptor so the allocator is inherited by all nested containers. More...
 
class  unordered_set
 Alias template for an STL container that uses a certain RawAllocator. More...
 
struct  unordered_set_node_size
 Contains the node size of a node based STL container with a specific type. More...
 
class  unordered_set_scoped_alloc
 Same as above but uses std::scoped_allocator_adaptor so the allocator is inherited by all nested containers. More...
 
class  vector
 Alias template for an STL container that uses a certain RawAllocator. More...
 
class  vector_scoped_alloc
 Same as above but uses std::scoped_allocator_adaptor so the allocator is inherited by all nested containers. More...
 
class  virtual_block_allocator
 A BlockAllocator that reserves virtual memory and commits it part by part. More...
 
class  virtual_memory_allocator
 A stateless RawAllocator that allocates memory using the virtual memory allocation functions. More...
 

Typedefs

using any_reference_storage = reference_storage< any_allocator >
 An alias for the reference_storage specialization using type-erasure. More...
 
using any_allocator_reference = allocator_storage< any_reference_storage, no_mutex >
 An alias for allocator_storage using the any_reference_storage. More...
 
using leak_handler = void(*)(const allocator_info &info, std::ptrdiff_t amount)
 The type of the handler called when a memory leak is detected. More...
 
using invalid_pointer_handler = void(*)(const allocator_info &info, const void *ptr)
 The type of the handler called when an invalid pointer is passed to a deallocation function. More...
 
using buffer_overflow_handler = void(*)(const void *memory, std::size_t size, const void *write_ptr)
 The type of the handler called when a buffer under/overflow is detected. More...
 
using default_allocator = FOONATHAN_IMPL_DEFINED(FOONATHAN_MEMORY_IMPL_DEFAULT_ALLOCATOR)
 The default RawAllocator that will be used as BlockAllocator in memory arenas. More...
 
using heap_allocator = FOONATHAN_IMPL_DEFINED(detail::lowlevel_allocator< detail::heap_allocator_impl >)
 A stateless RawAllocator that allocates memory from the heap. More...
 
using malloc_allocator = FOONATHAN_IMPL_DEFINED(detail::lowlevel_allocator< detail::malloc_allocator_impl >)
 A stateless RawAllocator that allocates memory using std::malloc(). More...
 
template<class BlockOrRawAllocator , template< typename... > class BlockAllocator = detail::default_block_wrapper>
using make_block_allocator_t = FOONATHAN_IMPL_DEFINED(typename std::conditional< is_block_allocator< BlockOrRawAllocator >::value, BlockOrRawAllocator, BlockAllocator< BlockOrRawAllocator > >::type)
 Takes either a BlockAllocator or a RawAllocator. More...
 
using new_allocator = FOONATHAN_IMPL_DEFINED(detail::lowlevel_allocator< detail::new_allocator_impl >)
 A stateless RawAllocator that allocates memory using (nothrow) operator new. More...
 
template<class Tracker , class BlockOrRawAllocator >
using deeply_tracked_block_allocator = FOONATHAN_IMPL_DEFINED(detail::deeply_tracked_block_allocator< Tracker, make_block_allocator_t< BlockOrRawAllocator > >)
 Similar to tracked_block_allocator, but shares the tracker with the higher level allocator. More...
 

Enumerations

enum  debug_magic : unsigned char {
  internal_memory, internal_freed_memory, new_memory, freed_memory,
  alignment_memory, fence_memory
}
 The magic values that are used for debug filling. More...
 

Functions

leak_handler set_leak_handler (leak_handler h)
 Exchanges the leak_handler. More...
 
leak_handler get_leak_handler ()
 Returns the leak_handler. More...
 
invalid_pointer_handler set_invalid_pointer_handler (invalid_pointer_handler h)
 Exchanges the invalid_pointer_handler. More...
 
invalid_pointer_handler get_invalid_pointer_handler ()
 Returns the invalid_pointer_handler. More...
 
buffer_overflow_handler set_buffer_overflow_handler (buffer_overflow_handler h)
 Exchanges the buffer_overflow_handler. More...
 
buffer_overflow_handler get_buffer_overflow_handler ()
 Returns the buffer_overflow_handler. More...
 
void * heap_alloc (std::size_t size) noexcept
 Allocates heap memory. More...
 
void heap_dealloc (void *ptr, std::size_t size) noexcept
 Deallocates heap memory. More...
 
template<class RawAllocator >
threshold_segregatable< typename std::decay< RawAllocator >::type > threshold (std::size_t max_size, RawAllocator &&alloc)
 
template<typename T , class RawAllocator , typename... Args>
auto allocate_unique (RawAllocator &&alloc, Args &&... args) -> FOONATHAN_REQUIRES_RET(!std::is_array< T >::value, std::unique_ptr< T, allocator_deleter< T, typename std::decay< RawAllocator >::type >>)
 Creates a std::unique_ptr using a RawAllocator for the allocation. More...
 
template<typename T , class RawAllocator , typename... Args>
auto allocate_unique (any_allocator, RawAllocator &&alloc, Args &&... args) -> FOONATHAN_REQUIRES_RET(!std::is_array< T >::value, std::unique_ptr< T, allocator_deleter< T, any_allocator >>)
 Creates a std::unique_ptr using a type-erased RawAllocator for the allocation. More...
 
template<typename T , class RawAllocator >
auto allocate_unique (RawAllocator &&alloc, std::size_t size) -> FOONATHAN_REQUIRES_RET(std::is_array< T >::value, std::unique_ptr< T, allocator_deleter< T, typename std::decay< RawAllocator >::type >>)
 Creates a std::unique_ptr owning an array using a RawAllocator for the allocation. More...
 
template<typename T , class RawAllocator >
auto allocate_unique (any_allocator, RawAllocator &&alloc, std::size_t size) -> FOONATHAN_REQUIRES_RET(std::is_array< T >::value, std::unique_ptr< T, allocator_deleter< T, any_allocator >>)
 Creates a std::unique_ptr owning an array using a type-erased RawAllocator for the allocation. More...
 
template<typename T , class RawAllocator , typename... Args>
std::shared_ptr< T > allocate_shared (RawAllocator &&alloc, Args &&... args)
 Creates a std::shared_ptr using a RawAllocator for the allocation. More...
 
temporary_stackget_temporary_stack (std::size_t initial_size=temporary_stack_initializer::default_stack_size)
 
void * virtual_memory_reserve (std::size_t no_pages) noexcept
 Reserves virtual memory. More...
 
void virtual_memory_release (void *pages, std::size_t no_pages) noexcept
 Releases reserved virtual memory. More...
 
void * virtual_memory_commit (void *memory, std::size_t no_pages) noexcept
 Commits reserved virtual memory. More...
 
void virtual_memory_decommit (void *memory, std::size_t no_pages) noexcept
 Decommits commited virtual memory. More...
 

Variables

const std::size_t virtual_memory_page_size
 The page size of the virtual memory. More...
 

Detailed Description

Memory namespace.

Function Documentation

◆ threshold()

threshold_segregatable<typename std::decay<RawAllocator>::type> foonathan::memory::threshold ( std::size_t  max_size,
RawAllocator &&  alloc 
)
Returns:
A threshold_segregatable with the same parameter.

◆ get_temporary_stack()

temporary_stack & get_temporary_stack ( std::size_t  initial_size = temporary_stack_initializer::default_stack_size)
Effects:
Creates the per-thread temporary_stack with the given initial size, if it wasn't already created.
Returns:
The per-thread temporary_stack.
Requires:
There must be a per-thread temporary stack (FOONATHAN_MEMORY_TEMPORARY_STACK_MODE must not be equal to 0).
Note
If FOONATHAN_MEMORY_TEMPORARY_STACK_MODE is equal to 1, this function can create the temporary stack. But if there is no temporary_stack_initializer, it won't be destroyed.