GC and memory : Why my material is still in memory?

I used this code to change material for a component at runtime:

MeshComponent->SetMaterial(0, NewMaterial);

After that i called ue4 gc manually,then uesd “memreport -full” to monitor memory used. I was surprised to find the old material was still in memory. I can sure that no other component use the old material in raw scene.

What’s more,i uesd “FReferenceChainSearch” to find that there was no reference with the old material at that time.

I don’t know why the old material is still in memory. Are there any other possibilities that could cause this phenomenon?

Can anyone tell me why? Or how to change material for a component at runtime so that the old material can be unloaded correctly.

Try to test it on StandAlone, even having the file asset material open window will keep it in the memory for some time.

If nothing is referencing an object, gc will collect it automatically around each 1min i believe and remove it from the memory.

Thank you for your reply. I didn’t make it clear. I actually run it on my phone, not the editor. It is true that it has a tag “RF_Standalone”, but it seems that it does not affect gc under non-editor conditions. I tried clearing the flag, but it didn’t work.

I don’t know what else will be affected. Even if nothing references it, it will still not be gc removed.

By the way, I discovered that the old material will be automatically cleared when the level of the component it was once associated with is unload. However, it no longer has a reference relationship with the previous component, and ReferenceChainSearch does return “***is not currently reachable.” But I cannot manually gc it.