Keeping track of what's loaded in memory?

Hi. This has been a pain for me from the start… Having worked with C++ almost exclusively, I am not really used to having a garbage collector and no control over the deletion of objects. I know exactly when I don’t need an object anymore and want to delete it, and it’s not hard to write code that keeps track of references and deals with them ON deletion, IF that’s what you want.

So, is there any way I can tell what’s currently loaded? Especially assets are a pain. I have lots of mesh variations and it’s absolutely necessary that unused meshes get unloaded from memory. How do I know? Is there some kind of notification in the log? Is there a command to get a list of what’s loaded? Maybe a function that tells me if an object is still referenced and therefore won’t be destroyed? I mean, I know what references I made myself, but I have no idea what the engine is linking “internally” and which of these links need to be cleared before destruction. For example: My skinned meshes have “two-sided” references with every single one of their own morph-targets… do I need to clear all these just to get the engine to free up the memory?

But it’s not just assets. Right now I’m wondering if UI Widgets get destroyed when I remove them from the viewport or if they linger in memory forever.

I was hoping to find some kind of OnDestroy-event array inside UObject. Then I could have added a delegate for giving out a notification myself. But that would only work with actor-derived classes it seems.

This discussion presents two interesting commands: Obj list and Obj refs.

You can also force gc every frame when you want to test what would stay loaded from your game with gc.CollectGarbageEveryFrame 1

1 Like