PrevUpHomeNext

Allocators

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 mqtt_client supports and utilises allocators associated with 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 mqtt_client'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 async_write on the transport layer.

Lastly, the mqtt_client uses boost::asio::recycling_allocator to allocate memory for its internal operations and components.


PrevUpHomeNext