diff --git a/rclcpp/include/rclcpp/strategies/allocator_memory_strategy.hpp b/rclcpp/include/rclcpp/strategies/allocator_memory_strategy.hpp index 655992df7a..b6424a524f 100644 --- a/rclcpp/include/rclcpp/strategies/allocator_memory_strategy.hpp +++ b/rclcpp/include/rclcpp/strategies/allocator_memory_strategy.hpp @@ -17,6 +17,7 @@ #include #include +#include #include "rcl/allocator.h" @@ -121,9 +122,10 @@ class AllocatorMemoryStrategy : public memory_strategy::MemoryStrategy } for (size_t i = 0; i < waitable_handles_.size(); ++i) { if (waitable_handles_[i]->is_ready(wait_set)) { - waitable_triggered_handles_.emplace_back(waitable_handles_[i]); + waitable_triggered_handles_.emplace_back(std::move(waitable_handles_[i])); } } + waitable_handles_.clear(); subscription_handles_.erase( std::remove(subscription_handles_.begin(), subscription_handles_.end(), nullptr), @@ -144,8 +146,6 @@ class AllocatorMemoryStrategy : public memory_strategy::MemoryStrategy std::remove(timer_handles_.begin(), timer_handles_.end(), nullptr), timer_handles_.end() ); - - waitable_handles_.clear(); } bool collect_entities(const WeakCallbackGroupsToNodesMap & weak_groups_to_nodes) override