Physical memory allocation
Throughout Genode, physical memory is allocated in the form of RAM dataspaces by using the Ram::Constrained_allocator interface. As indicated by its name, allocations are constrained by a resource budget and must be expected to fail for Alloc_error conditions. For brevity, Ram_allocator is provided as an alias. The interface is notably provided by the Env::ram() accessor, which allows a component to use its RAM budget for allocating RAM at a granularity of 4 KiB. After allocating, a RAM dataspace remains inaccessible by the component until locally mapped via Local_rm::attach. The allocated RAM dataspaces may serve as backing store for fine-grained component-local allocators such as the Heap (Section Component-local allocators). A RAM dataspace may be shared with other components by passing the allocated dataspace capability as an argument to an RPC.
Genode::Ram::Constrained_allocator
Accounted RAM allocations
The operations of the Ram::Constrained_allocator interface are the basis for Genode's RAM accounting. In cases where a server needs to allocate RAM on behalf of its clients, the interface provides a natural hook to track and constrain the client-specific RAM usage. The Ram::Accounted_allocator utility implements the interface by forwarding all operations to another RAM allocator instance while restricting allocations to a quota limit. Exceeding the limit results in the respective Alloc_error condition.