From 5c4282a21ca943e8afb3e7f15ac6fa4815197558 Mon Sep 17 00:00:00 2001 From: Yves Date: Mon, 17 Mar 2014 21:16:38 +0000 Subject: [PATCH] Fixes a small memory leak in the profiler shutdown code. This was SVN commit r14854. --- source/ps/Profiler2.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/ps/Profiler2.cpp b/source/ps/Profiler2.cpp index 9d8070774c..70eae0c1a2 100644 --- a/source/ps/Profiler2.cpp +++ b/source/ps/Profiler2.cpp @@ -195,7 +195,11 @@ void CProfiler2::Shutdown() m_MgContext = NULL; } - // TODO: free non-NULL keys, instead of leaking them + // the destructor is not called for the main thread + // we have to call it manually to avoid memory leaks + ENSURE(ThreadUtil::IsMainThread()); + void * dataptr = pthread_getspecific(m_TLS); + TLSDtor(dataptr); int err = pthread_key_delete(m_TLS); ENSURE(err == 0);