From 27112c468aaa1b1938facf6da679e097595ebbac Mon Sep 17 00:00:00 2001 From: Azaezel Date: Thu, 17 Sep 2015 16:14:49 -0500 Subject: [PATCH 1/2] reversion for https://github.com/GarageGames/Torque3D/commit/a4c09d168029dccac872b5816b21f8298f73f5e9 To be honest, can't remember how I was intending to fix that, but this one's causing it to fail to profile twice in a row, so kill it with fire. --- Engine/source/platform/profiler.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Engine/source/platform/profiler.cpp b/Engine/source/platform/profiler.cpp index ca34b4593..fb60453fc 100644 --- a/Engine/source/platform/profiler.cpp +++ b/Engine/source/platform/profiler.cpp @@ -214,12 +214,10 @@ Profiler::~Profiler() void Profiler::reset() { mEnabled = false; // in case we're in a profiler call. - ProfilerData * head = mProfileList; - ProfilerData * curr = NULL; - while ((curr = head) != NULL) + while (mProfileList) { - head = head->mNextProfilerData; - free(curr); + free(mProfileList); + mProfileList = NULL; } for(ProfilerRootData *walk = ProfilerRootData::sRootList; walk; walk = walk->mNextRoot) From 7418fbfbbdd2a7bebedd8f80a9a732de6544c036 Mon Sep 17 00:00:00 2001 From: Anis Date: Thu, 25 Feb 2016 18:26:15 +0100 Subject: [PATCH 2/2] fixed memory leak in proper way --- Engine/source/platform/profiler.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Engine/source/platform/profiler.cpp b/Engine/source/platform/profiler.cpp index fb60453fc..c978b9ac2 100644 --- a/Engine/source/platform/profiler.cpp +++ b/Engine/source/platform/profiler.cpp @@ -214,12 +214,22 @@ Profiler::~Profiler() void Profiler::reset() { mEnabled = false; // in case we're in a profiler call. - while (mProfileList) + ProfilerData * head = mProfileList; + ProfilerData * curr = head; + + while ( curr ) { - free(mProfileList); - mProfileList = NULL; + head = curr->mNextProfilerData; + free( curr ); + + if ( head ) + curr = head; + else + curr = NULL; } + mProfileList = NULL; + for(ProfilerRootData *walk = ProfilerRootData::sRootList; walk; walk = walk->mNextRoot) { walk->mFirstProfilerData = 0;