From 284d0c1c70c69e8378de3a185d6f324ae5abe04e Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Sat, 16 Mar 2019 00:55:53 +0800 Subject: [PATCH] fix wait for service memory leak bug (#656) * when call wait for service in an while loop, the event will be make forever and never release * fix it by: creating it when we need Signed-off-by: reed-lau --- rclcpp/src/rclcpp/client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rclcpp/src/rclcpp/client.cpp b/rclcpp/src/rclcpp/client.cpp index e784154..c2f64e0 100644 --- a/rclcpp/src/rclcpp/client.cpp +++ b/rclcpp/src/rclcpp/client.cpp @@ -118,7 +118,6 @@ ClientBase::wait_for_service_nanoseconds(std::chrono::nanoseconds timeout) if (!node_ptr) { throw InvalidNodeError(); } - auto event = node_ptr->get_graph_event(); // check to see if the server is ready immediately if (this->service_is_ready()) { return true; @@ -127,6 +126,7 @@ ClientBase::wait_for_service_nanoseconds(std::chrono::nanoseconds timeout) // check was non-blocking, return immediately return false; } + auto event = node_ptr->get_graph_event(); // update the time even on the first loop to account for time spent in the first call // to this->server_is_ready() std::chrono::nanoseconds time_to_wait =