FGenericPlatformMallocCrash

Simple pooled memory allocator that uses preallocated memory.

Windows
MacOS
Linux

Inheritance Hierarchy

FUseSystemMallocForNew

FExec

FMalloc

FGenericPlatformMallocCrash

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/GenericPlatform/GenericPlatformMallocCrash.h

Include

#include "GenericPlatform/GenericPlatformMallocCrash.h"

Syntax

struct FGenericPlatformMallocCrash : public FMalloc

Remarks

Simple pooled memory allocator that uses preallocated memory. Instance of this class replaces GMalloc after a crash, so we can use dynamic memory allocation even if the app crashes due to OOM.

Variables

Name Description

Protected variable

int32

 

CrashedThreadId

The id of the thread that crashed.

Protected variable

FCriticalSectio...

 

InternalLock

Used to lock crash malloc to one thread.

Protected variable

uint8 *

 

LargeMemoryPool

Preallocated memory pool for large allocations.

Protected variable

uint32

 

LargeMemoryPoolOffset

Current position in the large memory pool.

Protected variable

FMalloc *

 

PreviousMalloc

Previously used malloc.

Protected variable

uint8 *

 

SmallMemoryPool

Preallocated memory pool for small allocations.

Protected variable

uint32

 

SmallMemoryPoolOffset

Current position in the small memory pool.

Constructors

Name Description

Public function

FGenericPlatformMallocCrash

(
    FMalloc* MainMalloc
)

Destructors

Functions

Name Description

Protected function

uint8 *

 

AllocateFromSmallPool

(
    uint32 AllocationSize
)

Protected function Const

FMallocCrash...

 

FindPoolFromSize

(
    uint32 AllocationSize
)

Public function Static

FGenericPlat...

 

Get

(
    FMalloc* MainMalloc
)

Creates a new instance.

Protected function Static

uint32

 

GetAllocationSize

(
    void* Original
)

Protected function Const

const FPoolD...

 

GetPoolDesc

(
    uint32 Index
)

Generated by the FGenericPlatformMallocCrash::PrintPoolsUsage.

Protected function Const

uint32

 

GetSmallPoolTotalSize()

Protected function

void

 

InitializeSmallPools()

Protected function Const

bool

 

IsOnCrashedThread()

Whether it is safe to call crash malloc's methods.

Protected function Const

bool

 

IsPtrInLargePool

(
    void* Ptr
)

Protected function Const

bool

 

IsPtrInSmallPool

(
    void* Ptr
)

Public function

void

 

PrintPoolsUsage()

Protected function Static

uint32

 

SafePageSize()

Public function

void

 

SetAsGMalloc()

Sets as GMalloc.

Overridden from FMalloc

Name Description

Public function Virtual

void

 

Free

(
    void* Original
)

Free

Public function Virtual

bool

 

GetAllocationSize

(
    void* Original,
    SIZE_T& SizeOut
)

If possible determine the size of the memory allocated at the given address

Public function Virtual

const TCHAR ...

 

GetDescriptiveName()

Gets descriptive name for logging purposes.

Public function Virtual Const

bool

 

IsInternallyThreadSafe()

Returns if the allocator is guaranteed to be thread-safe and therefore doesn't need a unnecessary thread-safety wrapper around it.

Public function Virtual

void *

 

Malloc

(
    SIZE_T Count,
    uint32 Alignment
)

Malloc

Public function Virtual

void *

 

Realloc

(
    void* Original,
    SIZE_T Count,
    uint32 Alignment
)

Realloc

Public function Virtual

bool

 

ValidateHeap()

Validates the allocator's heap

Constants

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss