UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MallocJemalloc.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreGlobals.h"
6#include "CoreTypes.h"
7#include "HAL/MemoryBase.h"
9#include "Logging/LogMacros.h"
11
12class FOutputDevice;
13
14// Only use for supported platforms
15#if PLATFORM_SUPPORTS_JEMALLOC
16
17#define MEM_TIME(st)
18
19
20//
21// Jason Evans' malloc (default in FreeBSD, NetBSD, used in Firefox, Facebook servers)
22// http://www.canonware.com/jemalloc/
23//
25 : public FMalloc
26{
27public:
28
33 : MemTime(0.0)
34 { }
35
36public:
37
38 // FMalloc interface.
39
40 virtual void* Malloc( SIZE_T Size, uint32 Alignment ) override;
41 virtual void* Realloc( void* Ptr, SIZE_T NewSize, uint32 Alignment ) override;
42 virtual void Free( void* Ptr ) override;
43 virtual void DumpAllocatorStats( FOutputDevice& Ar ) override;
44 virtual bool GetAllocationSize(void *Original, SIZE_T &SizeOut) override;
45 virtual bool IsInternallyThreadSafe() const override { return true; }
46 virtual const TCHAR* GetDescriptiveName() override { return TEXT("jemalloc"); }
47
48protected:
49
50 void OutOfMemory( )
51 {
52 UE_LOG(LogHAL, Fatal, TEXT("%s"), TEXT("Ran out of virtual memory. To prevent this condition, you must free up more space on your primary hard disk.") );
53 }
54
55private:
56
58 double MemTime;
59};
60
61
62#endif // PLATFORM_SUPPORTS_JEMALLOC
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UE_LOG(CategoryName, Verbosity, Format,...)
Definition LogMacros.h:270
uint32 Size
Definition VulkanMemory.cpp:4034
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition MemoryBase.h:99
virtual const TCHAR * GetDescriptiveName()
Definition MemoryBase.h:248
virtual bool GetAllocationSize(void *Original, SIZE_T &SizeOut)
Definition MemoryBase.h:158
virtual void * Malloc(SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)=0
virtual bool IsInternallyThreadSafe() const
Definition MemoryBase.h:230
virtual void DumpAllocatorStats(class FOutputDevice &Ar)
Definition MemoryBase.h:221
virtual void * Realloc(void *Original, SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)=0
Definition OutputDevice.h:133