102 TopChunk =
Other.TopChunk;
103 TopMark =
Other.TopMark;
104 NumMarks =
Other.NumMarks;
108 Other.TopChunk =
nullptr;
110 Other.bShouldEnforceAllocMarks =
false;
122 return (
uint8*)
Alloc(AllocSize, FMath::Max(AllocSize >= 16 ? (
size_t)16 : (
size_t)8, Alignment));
132 inline void*
Alloc(
size_t AllocSize,
size_t Alignment)
152 AllocateNewChunk( AllocSize + Alignment );
153 Result =
Align( Top, Alignment );
154 NewTop = Result + AllocSize;
168 return TopChunk ==
nullptr;
225 uint8* Top =
nullptr;
226 uint8* End =
nullptr;
227 FTaggedMemory* TopChunk =
nullptr;
249 bShouldEnforceAllocMarks =
true;
294 return Mem.PushBytes(SizeInBytes, (
size_t)
Align);
310 uint8* Result = Mem.PushBytes(SizeInBytes, (
size_t)
Align);
328 uint8* Result = Mem.PushBytes(SizeInBytes, (
size_t)
Align);
344 return Mem.PushBytes(SizeInBytes, (
size_t)
Align);
360 uint8* Result = Mem.PushBytes(SizeInBytes, (
size_t)
Align);
378 uint8* Result = Mem.PushBytes(SizeInBytes, (
size_t)
Align);
389template<u
int32 Alignment = DEFAULT_ALIGNMENT>
398 template<
typename ElementType>
418 Other.Data =
nullptr;
433 static_assert(
sizeof(
int32) <=
sizeof(
SIZE_T),
"SIZE_T is expected to be larger than int32");
444 FMath::Max(Alignment,(
uint32)
alignof(ElementType))
470 return CurrentMax * NumBytesPerElement;
492template <u
int32 Alignment>
512 , SavedChunk(
InMem.TopChunk)
514 , NextTopmostMark(
InMem.TopMark)
533 check(Mem.TopMark ==
this);
540 if( SavedChunk != Mem.TopChunk )
542 Mem.FreeChunks( SavedChunk );
547 Mem.TopMark = NextTopmostMark;
constexpr T Align(T Val, uint64 Alignment)
Definition AlignmentTemplates.h:18
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define check(expr)
Definition AssertionMacros.h:314
UE_FORCEINLINE_HINT SizeType DefaultCalculateSlackReserve(SizeType NewMax, SIZE_T BytesPerElement, bool bAllowQuantize, uint32 Alignment=DEFAULT_ALIGNMENT)
Definition ContainerAllocationPolicies.h:223
UE_FORCEINLINE_HINT SizeType DefaultCalculateSlackShrink(SizeType NewMax, SizeType CurrentMax, SIZE_T BytesPerElement, bool bAllowQuantize, uint32 Alignment=DEFAULT_ALIGNMENT)
Definition ContainerAllocationPolicies.h:139
UE_FORCEINLINE_HINT SizeType DefaultCalculateSlackGrow(SizeType NewMax, SizeType CurrentMax, SIZE_T BytesPerElement, bool bAllowQuantize, uint32 Alignment=DEFAULT_ALIGNMENT)
Definition ContainerAllocationPolicies.h:169
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
T * NewOned(FMemStackBase &Mem, int32 Count=1, int32 Align=DEFAULT_ALIGNMENT)
Definition MemStack.h:269
EMemOned
Definition MemStack.h:30
@ MEM_Oned
Definition MemStack.h:31
EMemZeroed
Definition MemStack.h:24
@ MEM_Zeroed
Definition MemStack.h:25
T * New(FMemStackBase &Mem, int32 Count=1, int32 Align=DEFAULT_ALIGNMENT)
Definition MemStack.h:259
T * NewZeroed(FMemStackBase &Mem, int32 Count=1, int32 Align=DEFAULT_ALIGNMENT)
Definition MemStack.h:263
@ MIN_ALIGNMENT
Definition MemoryBase.h:27
@ DEFAULT_ALIGNMENT
Definition MemoryBase.h:24
#define MAX_int32
Definition NumericLimits.h:25
#define UE_DECLARE_THREAD_SINGLETON_TLS(Type, Api)
Definition ThreadSingleton.h:35
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32 Size
Definition VulkanMemory.cpp:4034
Definition MemStack.h:506
FMemMark(FMemStackBase &InMem)
Definition MemStack.h:509
void Pop()
Definition MemStack.h:529
~FMemMark()
Definition MemStack.h:523
UE_FORCEINLINE_HINT int32 GetNumMarks()
Definition MemStack.h:176
UE_FORCEINLINE_HINT bool IsEmpty() const
Definition MemStack.h:166
CORE_API bool ContainsPointer(const void *Pointer) const
Definition MemStack.cpp:398
UE_FORCEINLINE_HINT uint8 * GetTop() const
Definition MemStack.h:160
EPageSize
Definition MemStack.h:81
bool bShouldEnforceAllocMarks
Definition MemStack.h:239
void * Alloc(size_t AllocSize, size_t Alignment)
Definition MemStack.h:132
UE_FORCEINLINE_HINT uint8 * PushBytes(size_t AllocSize, size_t Alignment)
Definition MemStack.h:120
void Flush()
Definition MemStack.h:171
FMemStackBase(const FMemStackBase &)=delete
FMemStackBase & operator=(FMemStackBase &&Other)
Definition MemStack.h:97
FMemStackBase(FMemStackBase &&Other)
Definition MemStack.h:92
bool CanFitInPage(size_t AllocSize, size_t Alignment) const
Definition MemStack.h:125
CORE_API int32 GetByteCount() const
Definition MemStack.cpp:319
~FMemStackBase()
Definition MemStack.h:114
Definition MemStack.h:245
FMemStack()
Definition MemStack.h:247
CORE_API void * AllocSmall()
Definition MemStack.cpp:258
@ SmallPageSize
Definition MemStack.h:41
@ PageSize
Definition MemStack.h:40
CORE_API uint64 BytesUsed()
Definition MemStack.cpp:268
CORE_API uint64 BytesFree()
Definition MemStack.cpp:273
TLockFreeFixedSizeAllocator< PageSize, PLATFORM_CACHE_LINE_SIZE, FThreadSafeCounter > TPageAllocator
Definition MemStack.h:46
CORE_API void LatchProtectedMode()
Definition MemStack.cpp:280
CORE_API void FreeSmall(void *Mem)
Definition MemStack.cpp:263
static CORE_API FPageAllocator & Get()
Definition MemStack.cpp:30
CORE_API void * Alloc(int32 Alignment=MIN_ALIGNMENT)
Definition MemStack.cpp:236
CORE_API ~FPageAllocator()
Definition MemStack.cpp:25
Definition LockFreeFixedSizeAllocator.h:196
Definition MemStack.h:400
UE_FORCEINLINE_HINT SizeType CalculateSlackReserve(SizeType NewMax, SIZE_T NumBytesPerElement) const
Definition MemStack.h:455
ForElementType()
Definition MemStack.h:404
void MoveToEmpty(ForElementType &Other)
Definition MemStack.h:413
bool HasAllocation() const
Definition MemStack.h:473
UE_FORCEINLINE_HINT SizeType CalculateSlackShrink(SizeType NewMax, SizeType CurrentMax, SIZE_T NumBytesPerElement) const
Definition MemStack.h:459
UE_FORCEINLINE_HINT SIZE_T GetAllocatedSize(SizeType CurrentMax, SIZE_T NumBytesPerElement) const
Definition MemStack.h:468
SizeType GetInitialCapacity() const
Definition MemStack.h:478
UE_FORCEINLINE_HINT ElementType * GetAllocation() const
Definition MemStack.h:422
void ResizeAllocation(SizeType CurrentNum, SizeType NewMax, SIZE_T NumBytesPerElement)
Definition MemStack.h:428
UE_FORCEINLINE_HINT SizeType CalculateSlackGrow(SizeType NewMax, SizeType CurrentMax, SIZE_T NumBytesPerElement) const
Definition MemStack.h:463
Definition MemStack.h:391
@ NeedsElementType
Definition MemStack.h:395
@ RequireRangeCheck
Definition MemStack.h:396
ForElementType< FScriptContainerElement > ForAnyElementType
Definition MemStack.h:489
int32 SizeType
Definition MemStack.h:393
Definition ThreadSingleton.h:44
static FORCEINLINE FMemStack & Get()
Definition ThreadSingleton.h:101
implementation
Definition PlayInEditorLoadingScope.h:8
CORE_API void OnInvalidMemStackAllocatorNum(int32 NewNum, SIZE_T NumBytesPerElement)
Definition MemStack.cpp:415
@ false
Definition radaudio_common.h:23
Definition MemStack.h:203
uint8 * Data() const
Definition MemStack.h:207
FTaggedMemory * Next
Definition MemStack.h:204
int32 DataSize
Definition MemStack.h:205
static UE_FORCEINLINE_HINT void * Memzero(void *Dest, SIZE_T Count)
Definition UnrealMemory.h:131
static UE_FORCEINLINE_HINT void * Memcpy(void *Dest, const void *Src, SIZE_T Count)
Definition UnrealMemory.h:160
static UE_FORCEINLINE_HINT void * Memset(void *Dest, uint8 Char, SIZE_T Count)
Definition UnrealMemory.h:119
Definition ContainerAllocationPolicies.h:247
@ IsZeroConstruct
Definition ContainerAllocationPolicies.h:248
Definition ContainerAllocationPolicies.h:256
Definition NumericLimits.h:41