From 34894df1fb3b2a424ffa20d15c0c0ac05600e45e Mon Sep 17 00:00:00 2001 From: helius Date: Mon, 21 Oct 2019 16:35:44 +0800 Subject: [PATCH] fixed the Memory leaks of async event and async processmessages --- .../gazebo/physics/World.cc | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Gazebo_exercise/gazebo7_7.14.0_exercise/gazebo/physics/World.cc b/Gazebo_exercise/gazebo7_7.14.0_exercise/gazebo/physics/World.cc index 9ea63f9..fd22232 100644 --- a/Gazebo_exercise/gazebo7_7.14.0_exercise/gazebo/physics/World.cc +++ b/Gazebo_exercise/gazebo7_7.14.0_exercise/gazebo/physics/World.cc @@ -175,6 +175,21 @@ World::~World() delete this->dataPtr; this->dataPtr = nullptr; + ////////////////Added by zenglei for Asyn event and processMessages/////////////// + if (this->dataPtr->event_thread) + { + this->dataPtr->event_thread->join(); + delete this->dataPtr->event_thread; + this->dataPtr->event_thread = nullptr; + } + + if(this->dataPtr->async_processmessages_thread) + { + this->dataPtr->async_processmessages_thread->join(); + delete this->dataPtr->async_processmessages_thread; + this->dataPtr->async_processmessages_thread = nullptr; + } + ////////////////////////////////////////////////////////////////////////////////// } ////////////////////////////////////////////////// @@ -1352,6 +1367,24 @@ void World::Fini() delete this->dataPtr->thread; this->dataPtr->thread = nullptr; } + + /////////////////Added for asyn event by zenglei///////////////////// + + if (this->dataPtr->event_thread) + { + this->dataPtr->event_thread->join(); + delete this->dataPtr->event_thread; + this->dataPtr->event_thread = nullptr; + } + + if(this->dataPtr->async_processmessages_thread) + { + this->dataPtr->async_processmessages_thread->join(); + delete this->dataPtr->async_processmessages_thread; + this->dataPtr->async_processmessages_thread = nullptr; + } + + ////////////////////////////////////////////////////////////////////// } //////////////////////////////////////////////////