Documentation of memory

( foonathan/memory)

foonathan::memory Namespace Reference

Memory namespace. More...

Namespaces

 literals
 Literals namespace.
 

Classes

class  aligned_allocator
 A RawAllocator adapter that ensures a minimum alignment. 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, Mutex >
 Specialization of allocator_deallocator for array types. More...
 
class  allocator_deleter
 Similar to allocator_deallocator but calls the destructors of the objects. More...
 
class  allocator_deleter< Type[], RawAllocator, Mutex >
 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_reference
 An alias template for allocator_storage using the reference_storage policy with a given Mutex. 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< 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_allocator_reference
 A template alias for allocator_storage using the any_reference_storage with a given Mutex. 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  composable_allocator_traits
 The default specialization of the composable_allocator_traits for a ComposableAllocator. 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  direct_storage
 A StoragePolicy that stores the allocator directly. 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  growing_block_allocator
 A BlockAllocator that uses a given RawAllocator for allocating the blocks. 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  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  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  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_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  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...
 
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  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...
 
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  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  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...
 
struct  shared_ptr_node_size
 Contains the node size needed for a std::shared_ptr. 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  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  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_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_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_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_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  vector
 Alias template for an STL container that uses a certain RawAllocator. 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 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 = implementation_defined
 The default RawAllocator that will be used as BlockAllocator in memory arenas. More...
 
using heap_allocator = implementation_defined
 A stateless RawAllocator that allocates memory from the heap. More...
 
using malloc_allocator = implementation_defined
 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 = implementation_defined
 Takes either a BlockAllocator or a RawAllocator. More...
 
using new_allocator = implementation_defined
 A stateless RawAllocator that allocates memory using (nothrow) operator new. More...
 
using default_mutex = no_mutex
 The default Mutex type used as default template paremeter in, e.g. More...
 
template<class Tracker , class BlockOrRawAllocator >
using deeply_tracked_block_allocator = implementation_defined
 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<typename T , class RawAllocator , typename... Args>
auto allocate_unique (RawAllocator &&alloc, Args &&... args) -> 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) -> 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) -> 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) -> 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...
 
template<typename T , class RawAllocator , class Container = deque<T, RawAllocator>>
std::stack< T, Container > make_stack (RawAllocator &allocator)
 
template<typename T , class RawAllocator , class Container = deque<T, RawAllocator>>
std::queue< T, Container > make_queue (RawAllocator &allocator)
 
template<typename T , class RawAllocator , class Container = deque<T, RawAllocator>, class Compare = std::less<T>>
std::priority_queue< T, Container, Compare > make_priority_queue (RawAllocator &allocator, Compare comp={})
 
template<typename T , class RawAllocator , class Mutex >
bool operator== (std::nullptr_t, const joint_ptr< T, RawAllocator, Mutex > &ptr)
 
template<typename T , class RawAllocator , class Mutex >
bool operator== (T *p, const joint_ptr< T, RawAllocator, Mutex > &ptr)
 
template<typename T , class RawAllocator , class Mutex >
bool operator!= (std::nullptr_t, const joint_ptr< T, RawAllocator, Mutex > &ptr)
 
template<typename T , class RawAllocator , class Mutex >
bool operator!= (T *p, const joint_ptr< T, RawAllocator, Mutex > &ptr)
 
template<typename T , class RawAllocator , typename... Args>
auto allocate_joint (RawAllocator &alloc, joint_size additional_size, Args &&... args) -> joint_ptr< T, RawAllocator >
 
template<typename T , class RawAllocator , typename... Args>
auto allocate_joint (const RawAllocator &alloc, joint_size additional_size, Args &&... args) -> joint_ptr< T, RawAllocator >
 
template<class RawAllocator , typename T >
auto clone_joint (RawAllocator &alloc, const joint_type< T > &joint) -> joint_ptr< T, RawAllocator >
 
template<class RawAllocator , typename T >
auto clone_joint (const RawAllocator &alloc, const joint_type< T > &joint) -> joint_ptr< T, RawAllocator >
 
bool operator!= (const joint_allocator &lhs, const joint_allocator &rhs) noexcept
 
template<class BlockOrRawAllocator , typename... Args>
make_block_allocator_t< BlockOrRawAllocator > make_block_allocator (std::size_t block_size, Args &&... args)
 
template<template< class > class BlockAllocator, class BlockOrRawAllocator , typename... Args>
make_block_allocator_t< BlockOrRawAllocator, BlockAllocator > make_block_allocator (std::size_t block_size, Args &&... args)
 
bool operator!= (const memory_resource_allocator &lhs, const memory_resource_allocator &rhs) noexcept
 

Variables

const std::size_t virtual_memory_page_size
 The page size of the virtual memory. More...
 
constexpr bool cached_arena
 
constexpr bool uncached_arena
 

Detailed Description

Memory namespace.

Function Documentation

§ 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.