Navigation
API > API/Runtime > API/Runtime/Core
Provides Malloc operation that reduces per-malloc and per-free overhead by allocating in blocks, and not allowing individual calls to free. Does not free any malloc'd memory until the allocator goes out of scope. Intended use is dynamically allocated scratch data, or long-lived global allocations that never need to free data. Allocations at the end of each block waste memory: when the next requested allocation is too big for the current block, the remaining memory goes unused. To avoid large amounts of waste, allocations should be relatively small compared to blocksize.
Memory for the blocks is allocated from InnerMalloc->Malloc. If InnerMalloc is nullptr, GMalloc is used.
The LinearBlockAllocator must be destroyed before its InnerMalloc is destroyed; the InnerMalloc pointer is not reference counted.
| Name | FLinearBlockAllocator |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Memory/LinearAllocator.h |
| Include Path | #include "Memory/LinearAllocator.h" |
Syntax
class FLinearBlockAllocator : public FNoncopyable
Inheritance Hierarchy
- FNoncopyable → FLinearBlockAllocator
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Memory/LinearAllocator.h | |||
FLinearBlockAllocator
(
FMalloc* InInnerMalloc, |
Constructor. | Memory/LinearAllocator.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~FLinearBlockAllocator() |
Memory/LinearAllocator.h |
Structs
| Name | Remarks |
|---|---|
| FBlock |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| MinBlockSize | uint32 | Memory/LinearAllocator.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
SIZE_T GetAllocatedMemorySize() |
Returns the size of allocated blocks, which is >= size of pointers returned from Malloc calls. | Memory/LinearAllocator.h | |
void * Malloc
(
SIZE_T Size, |
Memory/LinearAllocator.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FBlock * AddCustomBlock
(
SIZE_T UserSize, |
Memory/LinearAllocator.h | ||
FBlock * AddDefaultBlock() |
Memory/LinearAllocator.h | ||
FBlock * AllocateBlock
(
uint32 BlockSize, |
Memory/LinearAllocator.h | ||
bool IsThreadSafe() |
Memory/LinearAllocator.h | ||
bool RequiresCustomAllocation
(
SIZE_T Size, |
Memory/LinearAllocator.h | ||
void * TryAllocateFromBlock
(
SIZE_T Size, |
Memory/LinearAllocator.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FLinearBlockAllocator & operator=
(
FLinearBlockAllocator&& |
Memory/LinearAllocator.h |