From d02519460202079c67e3eb06dc8921ab812963ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Wed, 20 Jan 2021 09:37:25 +0100 Subject: [PATCH] Remove thread after use to prevent memory leak --- core/os/thread.h | 2 +- modules/lightmapper_cpu/lightmapper_cpu.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/os/thread.h b/core/os/thread.h index ffc9149f85b..a0e9b109a46 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -71,7 +71,7 @@ public: static Error set_name(const String &p_name); _FORCE_INLINE_ static ID get_main_id() { return _main_thread_id; } ///< get the ID of the main thread static ID get_caller_id(); ///< get the ID of the caller function ID - static void wait_to_finish(Thread *p_thread); ///< waits until thread is finished, and deallocates it. + static void wait_to_finish(Thread *p_thread); ///< waits until thread is finished static Thread *create(ThreadCreateCallback p_callback, void *p_user, const Settings &p_settings = Settings()); ///< Static function to create a thread, will call p_callback virtual ~Thread(); diff --git a/modules/lightmapper_cpu/lightmapper_cpu.cpp b/modules/lightmapper_cpu/lightmapper_cpu.cpp index 44a03da7e55..ba07451cdf7 100644 --- a/modules/lightmapper_cpu/lightmapper_cpu.cpp +++ b/modules/lightmapper_cpu/lightmapper_cpu.cpp @@ -264,6 +264,7 @@ bool LightmapperCPU::_parallel_run(int p_count, const String &p_description, Bak } thread_cancelled = cancelled; Thread::wait_to_finish(runner_thread); + memdelete(runner_thread); #endif thread_cancelled = false;