Memory
Allocators, deallocators and memory manipulation.
Classes
-
DefaultAllocatorTag— General allocator provided by the OS. -
FrameAllocator— Frame allocator. -
TFrameAllocator— Version of FrameAllocator that allows blocks size to be provided through the template argument instead of the constructor. -
StdFrameAlloc— Allocator for the standard library that internally uses a frame allocator. -
StdFrameAlloc::rebind -
TShared— Reference counted object pointer that will keep the underlying object alive as long as the reference count is above 0. -
TWeak— References an object owned by a TShared. -
ISharedFromThis— Interface that allows a shared pointer to be retrieved from the this pointer. -
PoolAlloc— A memory allocator that allocates elements of the same size. -
StaticPoolAlloc— Helper class used by GlobalPoolAlloc that allocates a static pool allocator. -
GlobalPoolAlloc— Specializable template that allows users to implement globally accessible pool allocators for custom types. -
Any— Class capable of storing any general type, and safely extracting the proper type from the internal data. -
Any::Data
Structs
-
Deleter— Callable struct that acts as a proxy for B3DDelete -
StackMemory— Allocates memory on the stack and automatically frees it when it goes out of scope. -
FrameAllocatorScope— Opens a frame scope on construction and closes it on destruction. -
DataRange— Represents a range of memory containing sequential elements. -
TRange— Represents a range between two values. -
GlobalPoolAlloc::AlwaysFalse -
DataBlob— Serializable blob of raw memory.
Free functions
B3DAllocate
void *B3DAllocate(size_t count)
Allocates the specified number of bytes.
B3DAllocate
T *B3DAllocate()
Allocates enough bytes to hold the specified type, but doesn't construct it.
B3DNewMultiple
T *B3DNewMultiple(size_t count)
Creates and constructs an array of elements.
B3DNew
Type *B3DNew(Args &&...args)
Create a new object with the specified allocator and the specified parameters.
B3DFree
void B3DFree(void *ptr)
Frees all the bytes allocated at the specified location.
B3DDelete
void B3DDelete(T *ptr)
Destructs and frees the specified object.
B3DDeleteMultiple
void B3DDeleteMultiple(T *ptr, size_t count)
Destructs and frees the specified array of objects.
B3DAllocate
inline void *B3DAllocate(size_t count)
Allocates the specified number of bytes.
B3DAllocate
T *B3DAllocate()
Allocates enough bytes to hold the specified type, but doesn't construct it.
B3DAllocateAligned
inline void *B3DAllocateAligned(size_t count, size_t align)
Allocates the specified number of bytes aligned to the provided boundary.
Boundary is in bytes and must be a power of two.
B3DAllocateAligned16
inline void *B3DAllocateAligned16(size_t count)
Allocates the specified number of bytes aligned to a 16 bytes boundary.
B3DAllocateMultiple
T *B3DAllocateMultiple(size_t count)
Allocates enough bytes to hold an array of elements the specified type, but doesn't construct them.
B3DNewMultiple
T *B3DNewMultiple(size_t count)
Creates and constructs an array of elements.
B3DNew
Type *B3DNew(Args &&...args)
Create a new object with the specified allocator and the specified parameters.
B3DFree
inline void B3DFree(void *ptr)
Frees all the bytes allocated at the specified location.
B3DFreeAligned
inline void B3DFreeAligned(void *ptr)
Frees memory previously allocated with B3DAllocateAligned().
B3DFreeAligned16
inline void B3DFreeAligned16(void *ptr)
Frees memory previously allocated with B3DAllocateAligned16().
B3DStackAllocate
inline void *B3DStackAllocate(u32 amount)
Allocates the given amount of memory on the stack.
- amount
- The amount to allocate in bytes.
B3DStackAllocate
T *B3DStackAllocate()
Allocates enough memory to hold the specified type, on the stack, but does not initialize the object.
B3DStackAllocate
T *B3DStackAllocate(u32 amount)
Allocates enough memory to hold N objects of the specified type, on the stack, but does not initialize the objects.
- amount
- Number of entries of the requested type to allocate.
B3DStackNew
T *B3DStackNew(u32 count = 0)
Allocates enough memory to hold the specified type, on the stack, and constructs the object.
B3DStackNew
T *B3DStackNew(Args &&...args, u32 count = 0)
Allocates enough memory to hold the specified type, on the stack, and constructs the object.
B3DStackDelete
void B3DStackDelete(T *data)
Destructs and deallocates last allocated entry currently located on stack.
B3DStackDelete
void B3DStackDelete(T *data, u32 count)
Destructs an array of objects and deallocates last allocated entry currently located on stack.
B3DStackFree
inline void B3DStackFree(void *data)
Deallocates the given memory.
Data must be deallocated in opposite order then when it was allocated.
GetFrameAllocator
FrameAllocator &GetFrameAllocator()
Returns a global, application wide FrameAllocator.
Each thread gets its own frame allocator.
B3DFrameAllocate
u8 *B3DFrameAllocate(u32 byteCount)
Allocates some memory using the global frame allocator.
- byteCount
- Number of bytes to allocate.
B3DFrameAllocateAligned
u8 *B3DFrameAllocateAligned(u32 count, u32 align)
Allocates the specified number of bytes aligned to the provided boundary, using the global frame allocator.
Boundary is in bytes and must be a power of two.
B3DFrameFree
void B3DFrameFree(void *data)
Deallocates memory allocated with the global frame allocator.
B3DFrameFreeAligned
void B3DFrameFreeAligned(void *data)
Frees memory previously allocated with B3DFrameAllocateAligned().
B3DFrameAllocate
T *B3DFrameAllocate()
Allocates enough memory to hold the object of specified type using the global frame allocator, but does not construct the object.
B3DFrameAllocate
T *B3DFrameAllocate(u32 elementCount)
Allocates enough memory to hold N objects of specified type using the global frame allocator, but does not construct the object.
B3DFrameNew
T *B3DFrameNew(u32 elementCount = 0)
Allocates enough memory to hold the object(s) of specified type using the global frame allocator, and constructs them.
B3DFrameNew
T *B3DFrameNew(Args &&...args, u32 elementCount = 0)
Allocates enough memory to hold the object(s) of specified type using the global frame allocator, and constructs them.
B3DFrameDelete
void B3DFrameDelete(T *data)
Destructs and deallocates an object allocated with the global frame allocator.
B3DFrameDelete
void B3DFrameDelete(T *data, u32 elementCount)
Destructs and deallocates an array of objects allocated with the global frame allocator.
B3DMarkAllocatorFrame
void B3DMarkAllocatorFrame()
Marks the beginning of a new frame scope.
Increments the frame depth counter. The next call to Clear() will only clear memory allocated past this point.
B3DClearAllocatorFrame
void B3DClearAllocatorFrame()
Deallocates all allocated memory since the last call to MarkFrame() (or all the memory if there was no call to MarkFrame()).
Decrements the frame depth counter.
B3DZeroOut
void B3DZeroOut(T &s)
Sets contents of a struct to zero.
B3DZeroOut
void B3DZeroOut(T (&arr)[N])
Sets contents of a static array to zero.
B3DZeroOut
void B3DZeroOut(T *arr, size_t count)
Sets contents of a block of memory to zero.
B3DCopy
void B3DCopy(T (&dst)[N], T (&src)[N], size_t count)
Copies the contents of one array to another.
Automatically accounts for array element size.
B3DCopy
void B3DCopy(T *dst, const T *src, size_t count)
Copies the contents of one array to another.
Automatically accounts for array element size.
B3DSize
constexpr size_t B3DSize(const T (&array)[N])
Returns the size of the provided static array.
B3DSwapAndErase
bool B3DSwapAndErase(Vector<T, A> &container, const typename Vector<T, A>::iterator iter)
Erases the provided element from the container, but first swaps the element so its located at the end of the container, making the erase operation cheaper at the cost of an extra move operation.
Doesn't preserve ordering within the element. Returns true if a swap occurred, or false if the element was already at the end of the container.
B3DSwapAndErase
bool B3DSwapAndErase(Vector<T, A> &container, u32 index)
Erases the provided element from the container, but first swaps the element so its located at the end of the container, making the erase operation cheaper at the cost of an extra move operation.
Doesn't preserve ordering within the element. Returns true if a swap occurred, or false if the element was already at the end of the container.
B3DStaticPointerCast
TShared<T, ThreadSafety> B3DStaticPointerCast(const TShared<U, ThreadSafety> &other)
Cast a shared pointer from one type to another.
B3DStaticPointerCast
TShared<T, ThreadSafety> B3DStaticPointerCast(TShared<U, ThreadSafety> &&other)
Cast a shared pointer from one type to another.
B3DPoolAllocate
T *B3DPoolAllocate()
Allocates a new object of type T using the global pool allocator, without constructing it.
B3DPoolNew
T *B3DPoolNew(Args &&...args)
Allocates and constructs a new object of type T using the global pool allocator.
B3DPoolFree
void B3DPoolFree(T *ptr)
Frees the provided object using its global pool allocator, without destructing it.
B3DPoolDelete
void B3DPoolDelete(T *ptr)
Frees and destructs the provided object using its global pool allocator.
AnyCast
ValueType *AnyCast(Any *)
Returns a pointer to the internal data of the specified type.
AnyCastUnsafe
ValueType *AnyCastUnsafe(Any *)
Casts a type without performing any kind of checks.
AnyCast
const ValueType *AnyCast(const Any *operand)
Returns a const pointer to the internal data of the specified type.
AnyCast
ValueType AnyCast(const Any &operand)
Returns a copy of the internal data of the specified type.
AnyCast
ValueType AnyCast(Any &operand)
Returns a copy of the internal data of the specified type.
AnyCastRef
const ValueType &AnyCastRef(const Any &operand)
Returns a reference to the internal data of the specified type.
AnyCastRef
ValueType &AnyCastRef(Any &operand)
Returns a reference to the internal data of the specified type.
AnyCastUnsafe
const ValueType *AnyCastUnsafe(const Any *operand)
Casts a type without performing any kind of checks.
Internal
Symbols intended for engine-internal use. Not part of the public API.
Classes
-
FrameAllocator::MemoryBlock— A single block of memory within a frame allocator. -
PoolAlloc::MemBlock— A single block able to hold ElemsPerBlock elements. -
Any::DataBase -
MemoryCounter— Thread safe class used for storing total number of memory allocations and deallocations, primarily for statistic purposes. -
MemoryAllocatorBase— Base class all memory allocators need to inherit. -
MemoryAllocator— Memory allocator providing a generic implementation. -
StdAlloc— Allocator for the standard library that internally uses bsf memory allocator. -
StdAlloc::rebind -
MemStackInternal— Describes a memory stack of a certain block capacity. -
MemStackInternal::MemBlock— A single block of memory of BlockCapacity size. -
MemStack— One of the fastest, but also very limiting type of allocator. -
StackAllocatorTag— Allows use of a stack allocator by using normal new/delete/free/dealloc operators. -
FreeAlloc— Free allocator with no limitations, using traditional malloc/free under the hood. -
StaticAlloc— Static allocator that attempts to perform zero heap (dynamic) allocations by always keeping an active preallocated buffer. -
StaticAlloc::MemBlock— A single block of memory within a static allocator. -
StdStaticAlloc— Allocator for the standard library that internally uses a static allocator. -
StdStaticAlloc::rebind -
ProfilerAllocatorTag— Specialized allocator for profiler so we can avoid tracking internal profiler memory allocations which would skew profiler results. -
DefaultContainerAllocator— Default allocator that will be used by containers such as arrays. -
DefaultContainerAllocator::ForElementType -
InlineContainerAllocator— Allocator that will allocate -
InlineContainerAllocator::ForElementType -
CompressedPair— Stores two types, where the first type is guaranteed to have zero size if the type is empty. -
TSharedCommon— Base class class for TShared/TWeak. -
GroupAllocator— Provides an easy way to group multiple allocations under a single (actual) allocation.
Structs
-
TSharedControlBlock— Common based class for TShared/TWeak control blocks. -
TSharedControlBlockWithDefaultDeleter— Shared control block that deletes the references object using the default deleter. -
TSharedControlBlockWithCustomDeleter— Shared control block that deletes the references object using a user provided deleter. -
TSharedControlBlockWithObject— Shared control block that stores the referenced object within the control block itself. -
TSupportsSharedFromThis
Free functions
PlatformAlignedAlloc16
inline void *PlatformAlignedAlloc16(size_t size)
PlatformAlignedFree16
inline void PlatformAlignedFree16(void *ptr)
PlatformAlignedAlloc
inline void *PlatformAlignedAlloc(size_t size, size_t alignment)
PlatformAlignedFree
inline void PlatformAlignedFree(void *ptr)