UE4 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.

Leave a Comment