Manages memory blocks in a monotonically growing buffer with exception-free allocation and bundled deallocation.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 993d3b66f0fcProvenanceOpen questions (2)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Manages memory blocks in a monotonically growing buffer with exception-free allocation and bundled deallocation.
The class ara::core::MonotonicBufferResource provides a specialized memory resource for fast, monotonic allocations from a fixed memory buffer or via an upstream resource. Requested memory is allocated incrementally and is not freed immediately upon individual deallocations, but is instead reset collectively via release() ([SWS_CORE_06530]). All operations are declared completely exception-free, with an out-of-memory condition signaled by returning nullptr instead of an exception ([SWS_CORE_06569]). The instances are not copyable and require external synchronization for concurrent access from multiple threads.
Context
The class ara::core::MonotonicBufferResource is a concrete memory resource within the module core of the AUTOSAR Adaptive Platform and inherits from the base class ara::core::MemoryResource. It adapts the concept of std::pmr::monotonic_buffer_resource from [mem.res.monotonic.buffer], known from the C++ standard, for safety-relevant and deterministic automotive applications. The primary role of the class is to serve allocation requests with minimal management overhead from a contiguous memory area by allocating memory monotonically.
Calling components, polymorphic allocators, and containers that request memory blocks at runtime act as interaction partners on the one hand. On the other hand, the class interacts with an optional upstream memory resource (MemoryResource). This upstream resource can be passed via constructors such as [SWS_CORE_06521] and queried via the accessor method upstream_resource() ([SWS_CORE_06531]).
Lifecycle
The initialization of ara::core::MonotonicBufferResource can be controlled via multiple constructors. In addition to a parameterless default constructor ([SWS_CORE_06524]), overloads are available that accept an explicit upstream resource ([SWS_CORE_06521]), define an initial buffer size ([SWS_CORE_06525], [SWS_CORE_06522]), or utilize an externally provided raw memory area (void* buffer, std::size_t buffer_size) as the initial buffer ([SWS_CORE_06526], [SWS_CORE_06523]).
Regarding ownership semantics, the class is defined as strictly non-copyable: the copy constructor ([SWS_CORE_06527]) and the copy assignment operator ([SWS_CORE_06529]) are deleted (=delete). In contrast to the ISO 14882 standard, however, the AUTOSAR class implements explicit move semantics via the move constructor ([SWS_CORE_06576]) and the move assignment operator ([SWS_CORE_06577]), each defined as noexcept=default.
Destruction takes place via the destructor ~MonotonicBufferResource() ([SWS_CORE_06528]). A significant AUTOSAR deviation from the standard is that the destructor is not declared virtual. Via the method release() ([SWS_CORE_06530]), all allocated memory can be reset before the end of the object lifetime.
A typical application flow comprises provisioning, continuous allocation, and bundled deallocation:
Instantiation: The application creates an instance, for example by specifying a buffer size and an upstream resource ([SWS_CORE_06522]) or a fixed buffer ([SWS_CORE_06526]).
Allocation: Memory requests are served via the protected method do_allocate(bytes, alignment) ([SWS_CORE_06569]). If the available buffer is insufficient, the instance obtains a new buffer from the upstream resource.
Deallocation: Calls to do_deallocate(p, bytes, alignment) ([SWS_CORE_06570]) do not shrink the buffer individually; the internal allocation pointer advances monotonically.
Buffer reset: With release() ([SWS_CORE_06530]), all memory blocks obtained via upstream are released at once, and the buffer is ready for new cycles.
Resource comparison: Via do_is_equal() ([SWS_CORE_06571]), it can be checked whether two memory resources are identical.
The class follows strict requirements for exception-free embedded systems: all member functions, constructors, and operators are declared as noexcept and provide complete exception safety.
In the event of an error, the behavior deliberately deviates from the standard library:
Failed allocation: If a request in do_allocate() ([SWS_CORE_06569]) cannot be served, no exception std::bad_alloc is thrown; instead, nullptr is returned. Callers must check the return value for nullptr.
Error during deallocation: If an error occurs during deallocation in do_deallocate() ([SWS_CORE_06570]), it is silently ignored according to the specification.
Destruction via base pointer: Since the destructor ([SWS_CORE_06528]) is not virtual, destruction via a pointer to the base class MemoryResource is likely to lead to undefined behavior (Interpretation: destruction must occur via the concrete type). Question Q-add18020b48f3131 (open)
This guide was generated by an AI system based on the AUTOSAR Adaptive R25-11 specification.
except for the following deviations: 1. The function is noexcept 2. The function returns nullptr instead of (potentially) throwing a std::bad_alloc exception ≙ std::bad_alloc
As per corresponding usage in [mem.res.monotonic.buffer] except for the following deviations: 1. The function is noexcept 2. The function returns nullptr instead of (potentially) throwing a std::bad_alloc exception
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 601be17f5d68ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The protected member function do_allocate of class ara::core::MonotonicBufferResource serves for allocating memory areas according to [mem.res.monotonic.buffer][SWS_CORE_06569]. It implements the pure virtual interface do_allocate of base class ara::core::MemoryResource[SWS_CORE_06566]. As an interpretation, the synchronous call should primarily occur indirectly via the public allocation methods of the base class due to the protected visibility. Question Q-21b2da19c0fd7f8f (open) The function accepts the requested size in bytes as well as the desired alignment (alignment).
Error Handling and Exception Safety
In contrast to the C++ standard behavior, the function does not throw an std::bad_alloc exception on allocation errors, but returns a nullptr instead [SWS_CORE_06569]. Due to the declaration with noexcept, the method is specified as exception-safe [SWS_CORE_06569]. Callers must therefore always check the result for nullptr to detect insufficient memory.
Concurrency and Interaction
The method is specified as not thread-safe [SWS_CORE_06569]. If allocations are triggered concurrently from multiple threads, synchronization must occur externally via the calling site. This corresponds to the behavior of ara::core::UnsynchronizedPoolResource::do_allocate[SWS_CORE_00058], whereas ara::core::SynchronizedPoolResource::do_allocate is designed to be thread-safe for concurrent calls [SWS_CORE_00061].
This usage note was generated automatically based on specification AUTOSAR R25-11.
As per corresponding usage in [mem.res.monotonic.buffer] except for the following deviations: 1. The function is noexcept 2. If unsuccessful: errors will be silently ignored
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: e7d49ed79e7cProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The member function do_deallocate of class ara::core::MonotonicBufferResource serves for deallocating memory areas according to [SWS_CORE_06570]. It is defined via header file #include "ara/core/memory_resource.h"[SWS_CORE_06570]. The function takes a pointer p to the memory area to be deallocated as well as parameters bytes and alignment (each of type std::size_t) and returns no value (void) [SWS_CORE_06570]. The semantics follow the definition in [mem.res.monotonic.buffer] with specific AUTOSAR deviations [SWS_CORE_06570].
Error handling
The function is declared as noexcept and guarantees exception safety (exception safe) [SWS_CORE_06570]. If an error occurs during execution, it is silently ignored (errors will be silently ignored) [SWS_CORE_06570]. Neither return values nor specific error codes for error messages exist.
Concurrency and Limitations
Regarding concurrency, do_deallocate is specified as not thread-safe (not thread-safe) [SWS_CORE_06570]. Concurrent invocation from multiple threads without external synchronization is not permitted. The method has visibility protected and overrides the pure virtual interface of base class ara::core::MemoryResource[SWS_CORE_06567]. Interpretation: Calls should regularly be handled via the public deallocation interface of the base class. Question Q-6916292acaa8993b (open)
Interaction
While base class ara::core::MemoryResource specifies the deallocation method with private visibility [SWS_CORE_06567], MonotonicBufferResource as well as the related classes ara::core::SynchronizedPoolResource[SWS_CORE_00041] and ara::core::UnsynchronizedPoolResource[SWS_CORE_00059] implement it protected (protected) with silent error handling. In contrast to the synchronized pool resource [SWS_CORE_00041], which is thread-safe, MonotonicBufferResource like ara::core::UnsynchronizedPoolResource[SWS_CORE_00059] requires the exclusion of parallel accesses.
This usage note was created by an AI and is based on the definitions of specification AUTOSAR Adaptive R25-11.
As per corresponding usage in [mem.res.monotonic.buffer] except for the following deviations: 1. The function is noexcept
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: fc4ade44f9c3Provenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The protected method do_is_equal of class ara::core::MonotonicBufferResource overrides the pure virtual interface of base class ara::core::MemoryResource according to [SWS_CORE_06571]. It compares the current instance synchronously with a passed const MemoryResource &other for equality with respect to memory management semantics.
Usage and Semantics
The call typically occurs indirectly via the public interface of MemoryResource. According to [SWS_CORE_06571], the behavior follows the usage in [mem.res.monotonic.buffer], but exhibits the explicit deviation that the function is declared as noexcept. The return value is a bool indicating whether the two resources are interchangeable or identical.
Error Handling and Concurrency
Exception safety: The function is specified as exception safe and does not throw any exceptions due to the noexcept signature according to [SWS_CORE_06571]. Specific error codes or DET/DEM messages do not exist.
Thread safety: The operation is classified as thread-safe ([SWS_CORE_06571]) and can be executed concurrently.
Interaction
The function implements the virtual contract from ara::core::MemoryResource ([SWS_CORE_06568]). Similar implementations of the equality comparison can also be found in other memory resources such as ara::core::SynchronizedPoolResource ([SWS_CORE_00042]) and ara::core::UnsynchronizedPoolResource ([SWS_CORE_00060]).
This text was generated by an AI based on specification R25-11.
As per corresponding usage in [mem.res.monotonic.buffer] except for the following deviations: 1. The function is noexcept
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 082c843665ceProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The member function release() of class ara::core::MonotonicBufferResource ([SWS_CORE_06530]) serves for deallocating the memory managed by the buffer resource. The call is synchronous, takes no parameters, and returns no value (void).
Regarding error handling, the function is declared as noexcept and specified as exception-safe (exception safe) ([SWS_CORE_06530]). Specific error codes do not exist, and no error messages are dispatched to central diagnostic or reporting entities.
With regard to concurrency, release() is explicitly classified as not thread-safe (not thread-safe) ([SWS_CORE_06530]). Concurrent access to the same instance without external synchronization is not permitted. Interpretation: Due to the modeled semantics from [mem.res.monotonic.buffer], all memory areas previously provided via this resource should become invalid with the call. Question Q-bd46bd9971926d95 (open)
In the interplay of memory resources from #include "ara/core/memory_resource.h", the function differs in concurrency behavior from ara::core::SynchronizedPoolResource::release(), which is thread-safe ([SWS_CORE_00037]), while it behaves analogously to ara::core::UnsynchronizedPoolResource::release(), which is likewise not thread-safe ([SWS_CORE_00065]).
This text was generated by an AI based on the specification requirements of AUTOSAR R25-11.
As per corresponding usage in [mem.res.monotonic.buffer] except for the following deviations: 1. The function is noexcept
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 34a11a1fee7aProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The member function upstream_resource() of class ara::core::MonotonicBufferResource synchronously returns a pointer to the upstream memory resource of type MemoryResource*[SWS_CORE_06531]. The call is made via header #include "ara/core/memory_resource.h" and takes no parameters [SWS_CORE_06531]. Interpretation: The returned memory resource should act as an upstream buffer if the instance's internal buffer is insufficient for allocations. Question Q-e01e234e281bc4c6 (open)
Regarding error handling and exception safety, the method is declared as noexcept and completely exception-safe (exception safe) [SWS_CORE_06531]. Specific error codes, error objects, or diagnostic messages such as DET or DEM are not provided in the specification for this pure getter call [SWS_CORE_06531].
Regarding concurrency, the method is specified as const and thread-safe (thread-safe) [SWS_CORE_06531]. As a result, the pointer to the upstream resource can be queried from multiple threads in parallel without external synchronization.
The functional semantics follow the definition in [mem.res.monotonic.buffer], but exhibit the normative deviation that the function is explicitly defined as noexcept in the AUTOSAR Adaptive standard [SWS_CORE_06531]. An analogous interface pattern for providing the upstream resource is also used by the related classes ara::core::SynchronizedPoolResource[SWS_CORE_00038] and ara::core::UnsynchronizedPoolResource[SWS_CORE_00056].
This text was created by an AI based on the specification data.
As per corresponding usage in [mem.res.monotonic.buffer] except for the following deviations: 1. The function is noexcept 2. The function is not virtual
gemini-3.8-flash-low· 2026-10-13 · German original