memory
Typedefs | Member Functions
virtual_memory_allocator Class Reference

Detailed Description

A stateless RawAllocator that allocates memory using the virtual memory allocation functions.

It does not prereserve any memory and will always reserve and commit combined.

Typedefs

using is_stateful = std::false_type
 

Member Functions

 virtual_memory_allocator (virtual_memory_allocator &&) noexcept
 
virtual_memory_allocatoroperator= (virtual_memory_allocator &&) noexcept
 
void * allocate_node (std::size_t size, std::size_t alignment)
 
void deallocate_node (void *node, std::size_t size, std::size_t alignment) noexcept
 
std::size_t max_node_size () const noexcept
 
std::size_t max_alignment () const noexcept
 

Member Functions

◆ allocate_node()

void * allocate_node ( std::size_t  size,
std::size_t  alignment 
)
Effects:
A RawAllocator allocation function. It uses virtual_memory_reserve followed by virtual_memory_commit for the allocation. The number of pages allocated will be the minimum to hold size continuous bytes, i.e. size will be rounded up to the next multiple. If debug fences are activated, one additional page before and after the memory will be allocated.
Returns:
A pointer to a node, it will never be nullptr. It will always be aligned on a fence boundary, regardless of the alignment parameter.
Throws:
An exception of type out_of_memory or whatever is thrown by its handler if the allocation fails.

◆ deallocate_node()

void deallocate_node ( void *  node,
std::size_t  size,
std::size_t  alignment 
)
noexcept
Effects:
A RawAllocator deallocation function. It calls virtual_memory_decommit followed by virtual_memory_release for the deallocation.

◆ max_node_size()

std::size_t max_node_size ( ) const
noexcept
Returns:
The maximum node size by returning the maximum value.

◆ max_alignment()

std::size_t max_alignment ( ) const
noexcept
Returns:
The maximum alignment which is the same as the virtual_memory_page_size.