Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
MallocMimalloc.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreTypes.h"
5#include "HAL/PlatformMemory.h"
6#include "HAL/MemoryBase.h"
7
8#if !defined(PLATFORM_BUILDS_MIMALLOC)
9# define PLATFORM_BUILDS_MIMALLOC 0
10#endif
11
13# define PLATFORM_SUPPORTS_MIMALLOC 0
14#endif
15
17
19
20/**
21 * TBB 64-bit scalable memory allocator.
22 */
23class FMallocMimalloc final
24 : public FMalloc
25{
26public:
27 // FMalloc interface.
28 FMallocMimalloc();
29 virtual void* Malloc(SIZE_T Size, uint32 Alignment) override;
30 virtual void* TryMalloc(SIZE_T Size, uint32 Alignment) override;
31 virtual void* Realloc(void* Ptr, SIZE_T NewSize, uint32 Alignment) override;
32 virtual void* TryRealloc(void* Ptr, SIZE_T NewSize, uint32 Alignment) override;
33 virtual void Free(void* Ptr) override;
34 virtual bool GetAllocationSize(void *Original, SIZE_T &SizeOut) override;
35 virtual void Trim(bool bTrimThreadCaches) override;
36
37 virtual bool IsInternallyThreadSafe() const override
38 {
39 return true;
40 }
41
42 virtual const TCHAR* GetDescriptiveName( ) override
43 {
44 return TEXT("Mimalloc");
45 }
46
47protected:
48
49 void OutOfMemory( uint64 Size, uint32 Alignment )
50 {
51 // this is expected not to return
52 FPlatformMemory::OnOutOfMemory(Size, Alignment);
53 }
54};
55
56#endif
#define MIMALLOC_ENABLED
#define PLATFORM_SUPPORTS_MIMALLOC
#define PLATFORM_BUILDS_MIMALLOC
#define MIMALLOC_ALLOCATOR_ALLOWED