From 0548c8449aaeb7029d04a320353636ee733ed8db Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Wed, 6 Dec 2023 20:00:24 -0800 Subject: [PATCH] clean up the thread local memory regardless of managed thread's is around --- src/coreclr/vm/ceemain.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/coreclr/vm/ceemain.cpp b/src/coreclr/vm/ceemain.cpp index 1c58c941fb21a..218cda11d7f0e 100644 --- a/src/coreclr/vm/ceemain.cpp +++ b/src/coreclr/vm/ceemain.cpp @@ -1752,9 +1752,9 @@ struct TlsDestructionMonitor GCX_COOP_NO_DTOR_END(); } thread->DetachThread(TRUE); - DeleteThreadLocalMemory(); } + DeleteThreadLocalMemory(); ThreadDetaching(); } } @@ -1786,16 +1786,11 @@ void DeleteThreadLocalMemory() t_ThreadStatics.NonGCMaxThreadStaticBlocks = 0; t_ThreadStatics.GCMaxThreadStaticBlocks = 0; - if (t_ThreadStatics.NonGCThreadStaticBlocks != nullptr) - { - delete[] t_ThreadStatics.NonGCThreadStaticBlocks; - t_ThreadStatics.NonGCThreadStaticBlocks = nullptr; - } - if (t_ThreadStatics.GCThreadStaticBlocks != nullptr) - { - delete[] t_ThreadStatics.GCThreadStaticBlocks; - t_ThreadStatics.GCThreadStaticBlocks = nullptr; - } + delete[] t_ThreadStatics.NonGCThreadStaticBlocks; + t_ThreadStatics.NonGCThreadStaticBlocks = nullptr; + + delete[] t_ThreadStatics.GCThreadStaticBlocks; + t_ThreadStatics.GCThreadStaticBlocks = nullptr; } #ifdef DEBUGGING_SUPPORTED