Every asynchronous operation has an associated allocator designed to provide the operation with a consistent and stable memory source for the duration of its execution. This allocated memory, referred to as per-operation stable memory resources (POSMs), remains retained for the lifetime of the operation, ensuring its availability whenever needed. Asynchronous operations may utilise POSMs in numerous ways. See Allocators and Custom Memory Allocation for more information.
The
supports and utilises allocators associated with mqtt_client
async_xxx
's
handlers to store the state associated with the operation. Specifically,
the allocator is used to reserve memory for MQTT Control Packet bytes (PUBLISH
, SUBSCRIBE
,...) created by each
async_xxx
operation request.
Moreover, the
's internal
packet queue (described in the section Efficient bandwidth usage
with packet queuing in Optimising
communication) associates the allocator of the first packet in the
queue to the low-level Boost.Asio
function mqtt_client
async_write
on the
transport layer.
Lastly, the
uses mqtt_client
boost::asio::recycling_allocator
to allocate
memory for its internal operations and components.