<aside> 🗒️ Part of Ari's Unreal Engine Notes.
</aside>
Finding which UObjects are in memory and what references them to keep them alive is enough to solve most memory investigations. Use the following commands to help solve those issues:
obj gc
triggers garbage collection.obj list
prints a categorized list of all UObjects in memory sorted by how much memory each category takes.obj list class=x
where class
is the class name from the previous command will display every single object of that class, its full name and memory.obj refs name=/full/name/of/item.item shortest
prints the reference chain for what exactly is keeping it in memory using the full name from the previous command.obj list forget
makes UE not consider those objects for the next time you call obj list
, but instead list all new objects since the last time you called forget
.obj list remember
lists all objects normally again.gc.CollectGarbageEveryFrame 1
triggers a garbage collection every frame.gc.TimeBetweenPurgingPendingKillObjects [seconds]
overrides the default 60 second time between garbage collections.memreport -full
generates a diff-able memory report (-full is optional).obj
commands are handled in UEngine::HandleObjCommand (UnrealEngine.cpp:7098)
.
Advanced helper obj
commands in Obj.cpp:3719
.
Read the log to see the cause of World Memory Leak crashes. For most easy cases that should be enough to find the cause.
If the root object shouldn't be in memory at all then we need to figure out why it's being kept in memory during GC. Usually it will have the reason why GC doesn't consider it for collection in parenthesis if it's due to object flags, i.e. (asyncloading), (root), etc.
If those still don't help then the next section looks at general memory leak troubleshooting.
The reason why an object stays in memory is because either something is marking it as reachable by referencing it, or that the object was never even considered unreachable in the first place.