UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ArenaAllocator.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
7
8#define UE_API ULANGCORE_API
9
10namespace uLang
11{
12
18{
19public:
20
23
25
26 void * Allocate(uint32_t NumBytes);
27 UE_API void DeallocateAll();
28
29protected:
30
31 enum { Alignment = 8 };
32
33 static UE_API void * Allocate(const CAllocatorInstance * This, size_t NumBytes);
34 static UE_API void * Reallocate(const CAllocatorInstance * This, void * Memory, size_t NumBytes);
35 static UE_API void Deallocate(const CAllocatorInstance * This, void * Memory);
36
37 // Get more memory
39
42 {
44 };
45
49
50#if ULANG_DO_CHECK
55#endif
56};
57
58//=======================================================================================
59// CArenaAllocator Inline Methods
60//=======================================================================================
61
63{
64 NumBytes = AlignUp(NumBytes, Alignment);
65
66#if ULANG_DO_CHECK
67 ULANG_ASSERTF(NumBytes <= _ArenaSize, "Must not allocate a memory block larger than the arena size!");
68#endif
69
70 if (NumBytes > _BytesLeftInFirstArena)
71 {
73 }
74
76 _BytesLeftInFirstArena -= NumBytes;
77
78#if ULANG_DO_CHECK
80 _BytesAllocatedTotal += NumBytes;
81#endif
82
83 return Memory;
84}
85
86}
87
88#undef UE_API
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UE_API
Definition SColorGradingComponentViewer.h:12
#define ULANG_FORCEINLINE
Definition Common.h:188
#define ULANG_ASSERTF(expr, format,...)
Definition Common.h:290
Definition Allocator.h:35
Definition ArenaAllocator.h:18
const uint32_t _ArenaSize
Memory in each arena, in bytes.
Definition ArenaAllocator.h:47
UE_API void AllocateNewArena()
Definition ArenaAllocator.cpp:100
static UE_API void * Reallocate(const CAllocatorInstance *This, void *Memory, size_t NumBytes)
Definition ArenaAllocator.cpp:82
@ Alignment
Definition ArenaAllocator.h:31
static UE_API void Deallocate(const CAllocatorInstance *This, void *Memory)
Definition ArenaAllocator.cpp:89
UE_API ~CArenaAllocator()
Definition ArenaAllocator.cpp:22
uint32_t _BytesLeftInFirstArena
How much memory is available in the first arena.
Definition ArenaAllocator.h:48
SArenaHeader * _First
The first in the list of arenas.
Definition ArenaAllocator.h:46
UE_API void DeallocateAll()
Definition ArenaAllocator.cpp:57
void * Allocate(uint32_t NumBytes)
Definition ArenaAllocator.h:62
Definition VVMEngineEnvironment.h:23
ULANG_FORCEINLINE constexpr T AlignUp(T Val, uint64_t Alignment)
Definition Storage.h:93
Header of an arena, the allocated memory follows.
Definition ArenaAllocator.h:42
SArenaHeader * _Next
Definition ArenaAllocator.h:43