UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AndroidHeapProfiling.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#ifndef ANDROID_HEAP_PROFILING_SUPPORTED
6# define ANDROID_HEAP_PROFILING_SUPPORTED 0
7#endif
8
9#if ANDROID_HEAP_PROFILING_SUPPORTED
10 #include <type_traits>
11 #include "HAL/MallocAnsi.h"
12
13 uint32_t CreateHeap(const TCHAR* AllocatorName);
16#endif
17
18template <class T>
19struct FMallocProfilingProxy : public T
20{
21#if ANDROID_HEAP_PROFILING_SUPPORTED
23 {
24 static_assert(!std::is_same<T, FMallocAnsi>::value, "FMallocProfilingProxy should never be parametrized with FMallocAnsi since FMallocAnsi will be hooked by heapprofd internally");
25 HeapId = CreateHeap(T::GetDescriptiveName());
26 }
27
28 virtual void* Malloc(SIZE_T Size, uint32 Alignment) final
29 {
30 void* Ptr = T::Malloc(Size, Alignment);
32 return Ptr;
33 }
34
35 virtual void* TryMalloc(SIZE_T Size, uint32 Alignment) final
36 {
37 void* Ptr = T::Malloc(Size, Alignment);
38 if (Ptr)
39 {
41 }
42
43 return Ptr;
44 }
45
46 virtual void* Realloc(void* Ptr, SIZE_T NewSize, uint32 Alignment) final
47 {
48 if (Ptr != nullptr)
49 {
51 }
52
53 Ptr = T::Realloc(Ptr, NewSize, Alignment);
54
55 if (Ptr != nullptr)
56 {
58 }
59
60 return Ptr;
61 }
62
63 virtual void* TryRealloc(void* Ptr, SIZE_T NewSize, uint32 Alignment) final
64 {
65 return Realloc(Ptr, NewSize, Alignment);
66 }
67
68 virtual void Free(void* Ptr) final
69 {
71 T::Free(Ptr);
72 }
73
74private:
76#endif
77};
78
79
81{
82 static bool Init();
83};
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
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
uint32 HeapId
Definition MemoryTrace.h:30
const bool
Definition NetworkReplayStreaming.h:178
uint32 Size
Definition VulkanMemory.cpp:4034
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition AndroidHeapProfiling.h:81
static bool Init()
Definition AndroidHeapProfiling.cpp:40
Definition AndroidHeapProfiling.h:20