UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
InstanceCounter.h File Reference
#include "Containers/Map.h"
#include "Containers/UnrealString.h"
#include "CoreTypes.h"
#include "HAL/CriticalSection.h"
#include "HAL/PreprocessorHelpers.h"
#include "Misc/Build.h"
#include "UObject/NameTypes.h"

Go to the source code of this file.

Classes

class  FInstanceCountingObject
 
struct  FInstanceCountingObject::FGlobalVars
 

Macros

#define COUNT_INSTANCES(TypeName)    struct FCount##TypeName : FInstanceCountingObject { FCount##TypeName() : FInstanceCountingObject(TEXT(PREPROCESSOR_TO_STRING(TypeName))) {} }; FCount##TypeName TypeName##Count;
 
#define COUNT_INSTANCES_AND_LOG(TypeName)    struct FCount##TypeName : FInstanceCountingObject { FCount##TypeName() : FInstanceCountingObject(TEXT(PREPROCESSOR_TO_STRING(TypeName)), true) {} }; FCount##TypeName TypeName##Count;
 

Macro Definition Documentation

◆ COUNT_INSTANCES

#define COUNT_INSTANCES (   TypeName)     struct FCount##TypeName : FInstanceCountingObject { FCount##TypeName() : FInstanceCountingObject(TEXT(PREPROCESSOR_TO_STRING(TypeName))) {} }; FCount##TypeName TypeName##Count;

Add to class body of TypeName to track counts of "TypeName". Counts can be accessed via code or console

◆ COUNT_INSTANCES_AND_LOG

#define COUNT_INSTANCES_AND_LOG (   TypeName)     struct FCount##TypeName : FInstanceCountingObject { FCount##TypeName() : FInstanceCountingObject(TEXT(PREPROCESSOR_TO_STRING(TypeName)), true) {} }; FCount##TypeName TypeName##Count;

Identical to COUNT_INSTANCES, but construction/destruction will be written to the log along with the address of this object (us, not the instance that contains us)