I wonder how to safely delete a UObject within an FRunnable.

Greetings, I am facing an issue with multi-threaded garbage collection.

I have implemented prevetion of garbage collection using the AddToRoot() member function in the FRunnable environment, and upon the task’s completion, I called RemoveFromRoot. But I encounter a crash triggered by !isRooted. This issue arises only when the game ends. during gameplay, there are no problems(PIE environment). I have attempted to use ConditionalBeginDestroy and MarkAsPendingKill interchangedbly, but the result persistently remain the same.

Could you please help me figure out the best way to resolve this issue?
Thanks in advance.

Log:
[2024.03.21-05.17.14:322][317]LogPlayLevel: Display: Shutting down PIE online subsystems

[2024.03.21-05.17.14:337][317]LogWindows: Error: appError called: Assertion failed: !IsRooted() [Line: 265]

[2024.03.21-05.17.14:337][317]LogWindows: Error: appError called: Assertion failed: !IsRooted() [Line: 265]

[2024.03.21-05.17.18:258][317]LogWindows: Error: [Callstack] 0x00007ff8ce4cee9b UnrealEditor-Engine.dll!UE::Core::Private::Function::TFunctionRefCaller<ForEachObjectWithOuter'::2’::<lambda_1>,bool __cdecl(UObject *)>::Call() [(File Path)]
[2024.03.21-05.17.18:258][317]LogWindows: Error: [Callstack] 0x00007ff8cdc1649e UnrealEditor-CoreUObject.dll!ForEachObjectWithOuterBreakable()
[2024.03.21-05.17.18:258][317]LogWindows: Error: [Callstack] 0x00007ff8cf425a2a UnrealEditor-Engine.dll!UWorld::MarkObjectsPendingKill()
[2024.03.21-05.17.18:258][317]LogWindows: Error: [Callstack] 0x00007ff8985d6ddf UnrealEditor-UnrealEd.dll!UEditorEngine::EndPlayMap()
[2024.03.21-05.17.18:258][317]LogWindows: Error: [Callstack] 0x00007ff89833183a UnrealEditor-UnrealEd.dll!UEditorEngine::Tick()
[2024.03.21-05.17.18:258][317]LogWindows: Error: [Callstack] 0x00007ff898971b86 UnrealEditor-UnrealEd.dll!UUnrealEdEngine::Tick()
[2024.03.21-05.17.18:258][317]LogWindows: Error: [Callstack] 0x00007ff7941ff842 UnrealEditor.exe!FEngineLoop::Tick()
[2024.03.21-05.17.18:258][317]LogWindows: Error: [Callstack] 0x00007ff7941c35dc UnrealEditor.exe!GuardedMain()
[2024.03.21-05.17.18:258][317]LogWindows: Error: [Callstack] 0x00007ff79420658a UnrealEditor.exe!GuardedMainWrapper()
[2024.03.21-05.17.18:258][317]LogWindows: Error: [Callstack] 0x00007ff7942067e4 UnrealEditor.exe!LaunchWindowsStartup() [
[2024.03.21-05.17.18:258][317]LogWindows: Error: [Callstack] 0x00007ff794206ba4 UnrealEditor.exe!WinMain()
[2024.03.21-05.17.18:258][317]LogWindows: Error: [Callstack] 0x00007ff794209f32 UnrealEditor.exe!__scrt_common_main_seh()
[2024.03.21-05.17.18:258][317]LogWindows: Error: [Callstack] 0x00007ff98d8f7344 KERNEL32.DLL!UnknownFunction

For someone facing a problem like this, I suggest creating a container or implement AsyncTask. AsyncTask, in particular, offers the capability to access other threads, which can be beneficial in resolving the issue.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.