Download

[New Wiki] Memory Management, Count References to Any Object, and Know Who is Referring!

Dear Community,

I’ve just released a new wiki that shows you how you can count references to any AActor/UObject yourself!

You can also get an Object list of exactly who is referring to your UObject!

The code is quite simple, and I am using built-in runtime engine tools.

Garbage Collection ~ Count References to Any Object
https://wiki.unrealengine.com/Garbage_Collection_~_Count_References_To_Any_Object

Enjoy!

Rama

Sample output:



TArray<UObject*> Referencers;
 
GetObjReferenceCount(this,&Referencers);
 
for(UObject* Each : Referencers)
{
	if(Each)
	{
		UE_LOG(YourLog,Warning,TEXT("%s"), *Each->GetName());
	}
}


ObjRefCount.jpg

You are the best!

Thanks Rama, this should come in handy!

I noticed the return value in your example should probably be “ReferredToObjects.Num()” instead of the array pointer.

I changed the name in the code at one point and must have not added that, but it is correct now on the wiki, so all is well :slight_smile:

I hope you are having fun today!

Hee hee!

:heart:

Rama

Thanks Rama! Great stuff!

Thanks again, Rama! This is very useful information.