Do I need to store a reference after async loading a class asset to keep it in memory?

Zapking9224
Wed, 21 May 2025 03:56:07 +0000
Programming & Scripting

Hi everyone,

I’m working on an inventory system where each item is defined by a struct that contains metadata like the item’s name, description, mesh, and a soft reference to a class (e.g., for spawning a medkit actor).

At BeginPlay, I use “Async Load Class Asset” (Blueprint node) to load the class. However, I do not store the loaded class anywhere — I simply run the async load. Then, at any point in time, the player can choose to consume the item, and at that point I spawn an actor from the class.

So far, this works. But I’m wondering:

1. If I don’t store the loaded class in a variable after async loading it, can it be garbage collected later?

Or does the async load automatically keep it in memory until the class is used?

2. Is there a way to check whether a specific class is still loaded in memory during runtime?

3. Should I be caching the loaded class reference myself to ensure it doesn’t get unloaded before the player uses it?

4. Anything else I should know about managing asset lifetimes with soft class references and async loading?

I’m doing all of this in Blueprints.

Thanks in advance for any insights!

11 posts - 4 participants