UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PooledVirtualMemoryAllocator.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
7#include "HAL/PlatformMutex.h"
8
61{
63
65 void Free(void* Ptr, SIZE_T Size, UE::FPlatformRecursiveMutex* Mutex = nullptr, bool ThreadIsTimeCritical = false);
66 void FreeAll(UE::FPlatformRecursiveMutex* Mutex = nullptr);
67
77
84
86 void Refresh() {}
87
89 void UpdateStats() {}
90
92
93private:
94
95 enum Limits
96 {
97 NumAllocationSizeClasses = 64,
98 MaxAllocationSizeToPool = NumAllocationSizeClasses * 65536,
99
100 MaxOSAllocCacheSize = 64 * 1024 * 1024,
101 MaxOSAllocsCached = 64
102 };
103
114 UE_FORCEINLINE_HINT int32 GetAllocationSizeClass(SIZE_T Size)
115 {
116 return static_cast<int32>(Size >> 16) + ((Size & 0xFFFF) ? 1 : 0) - 1;
117 }
118
122 UE_FORCEINLINE_HINT SIZE_T CalculateAllocationSizeFromClass(int32 Class)
123 {
124 return (static_cast<SIZE_T>(Class) + 1) * 65536;
125 }
126
135 int32 NextPoolSize[Limits::NumAllocationSizeClasses];
136
138 FPoolDescriptorBase* ClassesListHeads[Limits::NumAllocationSizeClasses];
139
141 mutable UE::FPlatformRecursiveMutex ClassesLocks[Limits::NumAllocationSizeClasses];
142
147 void DecideOnTheNextPoolSize(int32 SizeClass, bool bGrowing);
148
150 FPoolDescriptorBase* CreatePool(SIZE_T AllocationSize, int32 NumPooledAllocations);
151
153 void DestroyPool(FPoolDescriptorBase* Pool);
154
156 UE::FPlatformRecursiveMutex OsAllocatorCacheLock;
157
160};
161
162#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_7
163# include "HAL/CriticalSection.h"
164#endif
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint32 Size
Definition VulkanMemory.cpp:4034
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition OutputDevice.h:133
FPThreadsRecursiveMutex FPlatformRecursiveMutex
Definition AndroidPlatformMutex.h:12
Definition PooledVirtualMemoryAllocator.h:70
SIZE_T VMSizeDivVirtualSizeAlignment
Definition PooledVirtualMemoryAllocator.h:75
FPoolDescriptorBase * Next
Definition PooledVirtualMemoryAllocator.h:72
Definition PooledVirtualMemoryAllocator.h:61
void Free(void *Ptr, SIZE_T Size, UE::FPlatformRecursiveMutex *Mutex=nullptr, bool ThreadIsTimeCritical=false)
void FreeAll(UE::FPlatformRecursiveMutex *Mutex=nullptr)
void * Allocate(SIZE_T Size, uint32 AllocationHint=0, UE::FPlatformRecursiveMutex *Mutex=nullptr)
uint64 GetCachedFreeTotal() const
uint64 GetCachedImmediatelyFreeable() const
Definition PooledVirtualMemoryAllocator.h:80
void DumpAllocatorStats(class FOutputDevice &Ar)
void Refresh()
Definition PooledVirtualMemoryAllocator.h:86
void UpdateStats()
Definition PooledVirtualMemoryAllocator.h:89
Definition CachedOSPageAllocator.h:37