diff --git a/include/boost/asio/detail/thread_info_base.hpp b/include/boost/asio/detail/thread_info_base.hpp index a05320ab..35c03cbb 100644 --- a/include/boost/asio/detail/thread_info_base.hpp +++ b/include/boost/asio/detail/thread_info_base.hpp @@ -66,7 +66,13 @@ public: ~thread_info_base() { for (int i = 0; i < max_mem_index; ++i) - ::operator delete(reusable_memory_[i]); + { + // The following test for non-null pointers is technically redundant, but + // it is significantly faster when using a tight io_context::poll() loop + // in latency sensitive applications. + if (reusable_memory_[i]) + ::operator delete(reusable_memory_[i]); + } } static void* allocate(thread_info_base* this_thread, std::size_t size)