Might be answers for you here: [Question] How to destroy an actor properly in C++? - Programming & Scripting - Unreal Engine Forums
Hi!
I’m trying to check if actor which was spawned and destroyed in runtime still exist in memory. I have this conditions:
if (MyActor != NULL)
{
UE_LOG(LogClass, Log, TEXT("There is Actor"));
}
else if (MyActor == NULL)
{
UE_LOG(LogClass, Log, TEXT("There is no Actor"));
}
Condition works like supposed to before I spawn MyActor. Also after I spawn actor, logs shows me correct infromation. But after MyActor has been destroyed (Destroy()) logs shows me that MyActor is still there. I suspect that this issue is related with Grabage Collector but I don’t have idea what to do with this. Any help?
I’ve checked upper link already but
MyActor = NULL;
this results editor crash
GetWorld()->ForceGarbageCollection(true);
this with the same result
When I set MyActor to NULL it looks like actor is over but it’s always couse editor crash.
if(!ActorRef) return;
if(!ActorRef->IsValidLowLevel()) return;
I’m trying to use this condition from Rama’s post but without any results because its always true. I tried also whole VDestroy(UObject * ToDestroy) function but this doesn’t work either (crash).
I came back to home and use another project. I mean that I work on two computers and copy source and content folder between them.
When I copied source back to my home computer … surprise - there’s no any of crash which I fought earlier.