hey, would it be possible to get an update of this code, with the wiki being shut down and all that?
im getting some really odd issues with GC and something like this would be extremely helpful for telling me what references arnt being resolved.
The link above seems to be about counting the objects that my object references. I needed a way to count all the objects that reference my object instead. This seems to be the first result on Google for that sort of question, so here’s what worked for me in UE 5.3:
I personally chose to use AllFlags for those parameters because I didn’t want to miss anything, but potentially some of the results could be CDOs, or partway through destruction, or otherwise unhelpful. There might be nicer values that would exclude those.
Also, that Reference variable there has some other nice information in it that I didn’t need but might be useful to you:
The number of times the Reference.Referencer object actually references Obj
The properties of the Reference.Referencer object that are actually doing the referencing, stored in Reference.ReferencingProperties.
IsReferenced function will set UE::GC::GUnreachableObjectFlag for unreachable objects, which will mess up ordinary GC flow. You can see that VerifyObjectFlags function will be called when GC starts to check that each object should not contain UE::GC::GUnreachableObjectFlag and UE::GC::GMaybeUnreachableObjectFlag.
After searching source code, I find that IsReferenced is only used by unreal editor, and there is no automatic GC before you click PIE. So I guess that unreal editor may do something like garbage purge after using IsReferenced function to keep things work.
For a safer choice, I would suggest to use FReferencerFinder::GetAllReferencers to find all objects that reference given objects, even though it don’t provide detailed reference counting and reference property.