Description
The allocator object responsible for managing the raw memory backing the array. Its type is the second template parameter of TArray (defaulting to FDefaultAllocator).
Caveats & Gotchas
- • Accessing AllocatorInstance directly bypasses all of TArray's element lifetime management (construction, destruction, move semantics). Writing to the raw allocation without going through TArray APIs will silently produce memory corruption.
- • For inline allocators (e.g. TInlineAllocator<N>), AllocatorInstance contains the stack buffer itself, not a pointer to it. This means copying a TArray with an inline allocator copies the entire stack buffer — be mindful of stack pressure for large inline sizes.
Signature
ElementAllocatorType AllocatorInstance Example
Custom allocator TArray declaration C++
// Use a stack-inline allocator for up to 8 elements before heap overflow:
TArray<FVector, TInlineAllocator<8>> SmallPath;
// AllocatorInstance here is a TInlineAllocator<8> holding 8 FVectors on the stack.
SmallPath.Add(FVector::ZeroVector); // no heap alloc See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?