Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
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"
8#include "Logging/LogCategory.h"
9#include "Logging/LogMacros.h"
10#include "Trace/Detail/Channel.h"
11
12class FOutputDevice;
13
14// Only use for supported platforms
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//
24class FMallocJemalloc
25 : public FMalloc
26{
27public:
28
29 /**
30 * Default constructor.
31 */
32 FMallocJemalloc()
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
57 /** Time spent on memory tasks, in seconds */
58 double MemTime;
59};
60
61
62#endif // PLATFORM_SUPPORTS_JEMALLOC
#define PLATFORM_SUPPORTS_JEMALLOC
Definition Platform.h:393