NewObject create in runtime caused crash 100% when exit pie

below is the crash details:

LoginId:ef10228c4e3579b942f57d9a5cffd305
EpicAccountId:6b9d7949c85f4b9b93da518f9fd29009

Assertion failed: false [File:D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\PlayLevel.cpp] [Line: 517] Object 'World /Game/Test/Gaea/Gaea1/UEDPIE_0_Gaea1Map.Gaea1Map' from PIE level still referenced. Shortest path from root: (PendingKill) (async) TCP_Idle_C /Game/Test/Gaea/Gaea1/UEDPIE_0_Gaea1Map.Gaea1Map:PersistentLevel.BP_Player_C_0.CharacterMesh0.ABP_Player_C_0.TCP_Idle_C_0 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ This reference is preventing the old World from being GC'd ^ -> UObject* UObject::Outer = (PendingKill) ABP_Player_C /Game/Test/Gaea/Gaea1/UEDPIE_0_Gaea1Map.Gaea1Map:PersistentLevel.BP_Player_C_0.CharacterMesh0.ABP_Player_C_0 -> UObject* UObject::Outer = (PendingKill) SkeletalMeshComponent /Game/Test/Gaea/Gaea1/UEDPIE_0_Gaea1Map.Gaea1Map:PersistentLevel.BP_Player_C_0.CharacterMesh0 -> UObject* UObject::Outer = (PendingKill) BP_Player_C /Game/Test/Gaea/Gaea1/UEDPIE_0_Gaea1Map.Gaea1Map:PersistentLevel.BP_Player_C_0 -> UObject* UObject::Outer = (PendingKill) Level /Game/Test/Gaea/Gaea1/UEDPIE_0_Gaea1Map.Gaea1Map:PersistentLevel -> UObject* UObject::Outer = (PendingKill) World /Game/Test/Gaea/Gaea1/UEDPIE_0_Gaea1Map.Gaea1Map

UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
kernel32
ntdll

the object which caused this crash is created runtime, i mean out of BeginPlay. it does not matter it is created or recreated, as long as it is created not in beginPlay, it will certainly cause crash.

below is the code which creates the object which causes this crash.

	auto& TransitionCheckerHolder = TransitionCheckerHolders[Checker];
	if (!TransitionCheckerHolder.AnimationTransitionCheckerClass)
	{
		return false;
	}
	if (!TransitionCheckerHolder.AnimationTransitionChecker.IsValid())
	{
		GEngine->AddOnScreenDebugMessage(-1, 70.F, FColor::Cyan, FString::Printf(TEXT("New Checker created for %s"), *Checker.ToString()));
		TransitionCheckerHolder.AnimationTransitionChecker = NewObject<UX2AnimationTransitionCheckerBase>(this, TransitionCheckerHolder.AnimationTransitionCheckerClass);
	}
	return TransitionCheckerHolder.AnimationTransitionChecker->CheckTransition(this);

Have you used AddToRoot anywhere? looks like something is stopping it from being garbage collected

yes, but it will crash in the runtime, not the exiting phase. much worse than the current one, which is somehow acceptable.

try manually destroying the object before you close the level,

but if you just dont want it to be garbage collected i’d suggest using the GameInstance and an outer and make sure you save a reference to the object.

i want it to be destroyed with the pie. manually destroy the object does not solve the problem, thanks.

GameInstance should be fine then, just dont use AddToRoot

or even use a GameInstance Subsystem instead of the UObject

use a far more big scope object as outer will certainly cause gc problem sooner or later. i’ll try gameinstance, but i think i will never accept this solution.