How do you debug if an asset is in memory during gameplay?

Hi! I am trying to understand the soft references usage, data assets, etc.
I saw a couple youtube tut vids. and cmd command Obj list class= someclass will show a list of objects of that class in memory. the thing is that is showing me all that is in the editor folders already during gameplay…does that means everything in the editor is in the memory already even if I am not calling it from my objects?

  1. I type this:
Obj list class=texture

it gives a long list of default editor assets like this:


                                                                                                                                      Object      NumKB      MaxKB   ResExcKB  ResExcDedSysKB  ResExcShrSysKB  ResExcDedVidKB  ResExcShrVidKB     ResExcUnkKB
                                                                              Texture2D /Engine/EditorResources/LightIcons/SkyLight.SkyLight       1.02       1.03     256.00            0.00            0.00          256.00            0.00            0.00
                                                       Texture2D /Engine/EngineMaterials/T_Default_Material_Grid_M.T_Default_Material_Grid_M       1.00       1.02     341.36            0.00            0.00          341.36            0.00            0.00
                                                       Texture2D /Engine/EngineMaterials/T_Default_Material_Grid_N.T_Default_Material_Grid_N       1.00       1.02      85.36            0.00            0.00           85.36            0.00            0.00
                                                              Texture2D /Engine/EditorResources/LightIcons/S_LightPointMove.S_LightPointMove       0.98       1.00     256.00            0.00            0.00          256.00            0.00            0.00
                                                                Texture2D /Paper2D/PlaceholderTextures/DummySpriteTexture.DummySpriteTexture       0.98       1.00       5.36            0.00            0.00            5.36            0.00            0.00
                                                                      Texture2D /Engine/EditorResources/LightIcons/S_LightError.S_LightError       0.98       1.00     256.00            0.00            0.00          256.00            0.00            0.00
                                                                Texture2D /Engine/EditorResources/LightIcons/S_LightSpotMove.S_LightSpotMove       0.98       1.00     256.00            0.00            0.00          256.00            0.00            0.00
                                                               Texture2D /Engine/EditorResources/S_TextRenderActorIcon.S_TextRenderActorIcon       0.98       0.99       5.36            0.00            0.00            5.36            0.00            0.00
                                                                           Texture2D /Engine/EditorResources/S_ReflActorIcon.S_ReflActorIcon       0.98       0.99       5.36            0.00            0.00            5.36            0.00            0.00
                                                                           Texture2D /Engine/EditorResources/S_ExpoHeightFog.S_ExpoHeightFog       0.97       0.99      21.33            0.00            0.00           21.33            0.00            0.00
                                                                       Texture2D /Engine/EditorResources/S_WindDirectional.S_WindDirectional       0.97       0.99       5.36            0.00            0.00            5.36            0.00            0.00
                                                                      Texture2D /Engine/EditorResources/LightIcons/S_LightPoint.S_LightPoint       0.97       0.98     256.00            0.00            0.00          256.00            0.00            0.00
                                               Texture2D /Engine/EditorMaterials/WidgetGridVertexColorMaterial.WidgetGridVertexColorMaterial       0.96       0.98       2.68            0.00            0.00            2.68            0.00            0.00
                                                                        Texture2D /Engine/EditorResources/LightIcons/S_LightSpot.S_LightSpot       0.96       0.98     256.00            0.00            0.00          256.00            0.00            0.00
                                                                                    Texture2D /Engine/EditorResources/AI/S_NavLink.S_NavLink       0.96       0.98      64.00            0.00            0.00           64.00            0.00            0.00
                                                                                     Texture2D /Engine/EditorResources/S_Thruster.S_Thruster       0.96       0.98      21.33            0.00            0.00           21.33            0.00            0.00
                                                                                       Texture2D /Engine/EditorResources/S_Emitter.S_Emitter       0.96       0.97      21.33            0.00            0.00           21.33            0.00            0.00
                                                                                       Texture2D /Engine/EditorResources/S_Terrain.S_Terrain       0.96       0.97      21.33   

.
.
.

even if I add some new textures in my editor folders and type that command, those new textures are listed too even If no object in the level is calling it.

can someone explain me this? all default EDITOR assets will live in memory even at runtime?
why added assets to the editor resides in memory already even if I dont call em in any object?

thanks

Everything you open in the Editor is necessarily in-memory: the editor and game engine aren’t separate. So if you open a texture for editing, or open any other asset that references that texture (or asset that references an asset that references an asset that…), then it’ll get loaded. Assets that are closed and unreferenced by anything else will eventually be evicted from memory by the garbage collector.

The editor won’t load things till they’re needed, but there’s a ton of stuff that’ll get loaded through reference chains even when you’re just opening a level at startup. If you’ve only got soft refs to an asset, it won’t be loaded until someone tries to use it. But if anything else in the game/editor has a hard reference to it, it’ll get loaded anyway.

Creating a new asset involves generating it in memory, then (optionally) writing it to disc. So it’s not surprising new textures would be in memory after you’ve created them. If you create and save a new texture, don’t reference it, and restart the editor, I think you’ll find the texture isn’t in memory.

Hi! thanks for your reply and you’re totally right. But…is there some ‘FLUSH EDITOR MEMORY’ command or something like that to avoid restart the editor each time I want to check? Is just for testing what is actually loaded once I run the game. Because as you say…maybe some other asset is queryng some hard reference already and all my soft reference work is useless :slight_smile:

Your first stop should be the reference viewer in the editor (right-click the asset), which lets you see what’s statically referencing your asset. You can increase “depth” to see further along the chain in either direction.

To see what’s referencing an asset right now (i.e. hard refs by objects that are in memory), run obj refs name=Asset_Name. If that comes back as “not currently reachable” then you’re good, the asset won’t be forcibly kept in memory in-game. Whether it does actually remain in memory is up to the engine.

You can run obj gc to force a GC pass, but in my experience it’s not very aggressive for loaded assets in the editor - they tend to stay loaded.

3 Likes

thanks!! Very usefull info in a single post :slight_smile: