[toc]
unreal app is initialized via FAppEntry::Init()
, no matter what platform.
Most (near all) Z_Construct_UClass_XXX()
fuctions are called only in the initialization stage via ProcessNewlyLoadedUObjects()
.
Z_Construct_UClass_XXX()
are functions that construct the unreal "class reflection data". These functions' code are generated by macro in Runtime/CoreUObject/Public/UObject/ObjectMacros.h:
// Used for intrinsics, this sets up the boiler plate, plus an initialization singleton, which can create properties and GC tokens
#define IMPLEMENT_INTRINSIC_CLASS(TClass, TRequiredAPI, TSuperClass, TSuperRequiredAPI, TPackage, InitCode) \
IMPLEMENT_CLASS(TClass, 0) \
TRequiredAPI UClass* Z_Construct_UClass_##TClass(); \
struct Z_Construct_UClass_##TClass##_Statics \
{ \
static UClass* Construct() \
{ \
extern TSuperRequiredAPI UClass* Z_Construct_UClass_##TSuperClass(); \
UClass* SuperClass = Z_Construct_UClass_##TSuperClass(); \
UClass* Class = TClass::StaticClass(); \
UObjectForceRegistration(Class); \
check(Class->GetSuperClass() == SuperClass); \
InitCode \
Class->StaticLink(); \
return Class; \
} \
}; \
UClass* Z_Construct_UClass_##TClass() \
{ \
static UClass* Class = NULL; \
if (!Class) \
{ \
Class = Z_Construct_UClass_##TClass##_Statics::Construct();\
} \
check(Class->GetClass()); \
return Class; \
} \
...
most of heap memory is allocated via FMallocBinned::Malloc()
.
FMallocBinned
is in Runtime/Core/Public/HAL/MallocBinned.h, it's commentted as "Optimized virtual memory allocator",
Only in Windows has global operator new, which means, unlike Unity, your code's new operator is not managed by the engine, and is just handled by the operating system.
#ifdef OVERRIDE_NEW_DELETE
#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) || defined(__WIN32__) || defined(__WINDOWS__)
#include <malloc.h>
void* operator new(size_t size)
{
void* p = malloc(size);
MEMPRO_TRACK_ALLOC(p, size);
return p;
}
void operator delete(void* p)
{
MEMPRO_TRACK_FREE(p);
free(p);
}
...
#endif
#endif