How to tell if my objects were destroyed and garbage collected ??

I’m procedurally generating lots of skeletal meshes in my project. On top of that there are a couple of UObject-derived gameplay classes that are being referenced and managed by the game-instance and are therefore level-independent.

But I still haven’t figured out a way to tell, if objects I no longer need are getting destroyed and cleaned up or if they persist in memory and create a memory leak.

I thought maybe I could find all objects as subobjects of the “TransientPackage”, but it doesn’t look like it (or I’m doing it wrong). There’s just 1 subobject all the time…

I also thought about implementing a BeginDestroy in my classes that tells me about the destruction somehow, BUT I can’t do that for the SkeletalMeshes. And this information wouldn’t be as useful as getting a list of loaded transient objects.

So, any ideas?

One option is with the console. Run your project in PIE, then open the console (` key) and type:
obj list class=SkeletalMesh
or whatever class of object you want to check on. There are also some other filters that will be shown as you type in the command.

Thanks, I’m gonna try that tonight. Do you know where the editor is getting the list from? I mean, is there a way to get hold of those objects in code? That would allow me to better analyze what’s keeping objects from being destroyed and more.

Sorry no I’ve only used the console command, so not sure what code is responsible for walking the reference graph.

You could just temporarily create a class derived from USkeletalMesh and use that, allowing you to override the destructor or similar and track what’s happening.

Maybe this thread/wiki by Rama can help you? [New Wiki] Memory Management, Count References to Any Object, and Know Who is Referring!](!&highlight=object+references)

I need to revive this topic. After being busy with other stuff, I finally want to deal with this memory problem. So, that console command is helpful in finding out IF objects have been destroyed. I used it and found that my procedural skeletal meshes don’t get destroyed. But I don’t know what’s keeping them from being garbage collected. I don’t know of any references that still exist at the time I don’t need them anymore. That code from Rama, if I understand it correctly, is meant to find references BY a specific object. But I need to know what objects still have references TO a specific object (the skeletal mesh). I tried this console command: AssetRegistry.GetReferencers <path>. But whatever I set as path, the console tells me it can’t find anything, no matter if it’s a transient object or not.

I don’t know that command, but I’d guess it’s only for static references between assets.

Use the obj list command to get the name of an object you’re interested in, making sure it’s one rooted in the PIE instance of the map and not the map in the asset.
Then enter: obj refs name=<full path and name of object, starting with /Game…>
That should list the reference chains ending in the specified object.

Thanks a lot! Turned out I didn’t clear the “StandAlone” flag on my copied meshes, even though I was sure I did. Bitwise operations always manage to confuse me… Looks like they are getting garbage collected now. But that command will definitely come in handy next time.