diff --git a/websocketpp/impl/connection_impl.hpp b/websocketpp/impl/connection_impl.hpp index bf88c9552..01935f53f 100644 --- a/websocketpp/impl/connection_impl.hpp +++ b/websocketpp/impl/connection_impl.hpp @@ -1895,7 +1895,11 @@ void connection::handle_write_frame(lib::error_code const & ec) bool terminal = m_current_msgs.back()->get_terminal(); m_send_buffer.clear(); + m_send_buffer.shrink_to_fit(); + m_current_msgs.clear(); + m_current_msgs.shrink_to_fit(); + // TODO: recycle instead of deleting if (ec) { diff --git a/websocketpp/transport/asio/connection.hpp b/websocketpp/transport/asio/connection.hpp index 57dda74a2..8954147ee 100644 --- a/websocketpp/transport/asio/connection.hpp +++ b/websocketpp/transport/asio/connection.hpp @@ -674,6 +674,8 @@ class connection : public config::socket_type::socket_con_type { } m_bufs.clear(); + m_bufs.shrink_to_fit(); + // Timer expired or the operation was aborted for some reason. // Whatever aborted it will be issuing the callback so we are safe to @@ -979,6 +981,7 @@ class connection : public config::socket_type::socket_con_type { */ void handle_async_write(write_handler handler, lib::asio::error_code const & ec, size_t) { m_bufs.clear(); + m_bufs.shrink_to_fit(); lib::error_code tec; if (ec) { log_err(log::elevel::info,"asio async_write",ec);