pub struct AllocatorLimits { /* private fields */ }Expand description
Process-wide limits on custom receive allocation.
The limits cover every receiver in the process, including allocations made
by policies that have since been replaced and buffers whose release is
still in progress. Memory a policy allocates for its own bookkeeping is not
counted. A request the limits do not admit is declined, and the SDK then
drops that frame. AllocatorService::usage reports these declines through
AllocatorUsage::declined and AllocatorUsage::declined_allocations.
The defaults are 256 generations, 1024 allocations, 1 GiB in total, 16 concurrent calls and 64 MiB per allocation, which holds a packed 7680×4320 8-bit 4:2:2 frame.
§How the limits combine
A policy may return a larger buffer than the frame needs, so each call is
granted its buffer before the policy runs: the largest single allocation,
or what is left of the byte budget when that is less. A call is declined
only when its grant cannot hold the frame, and it counts as an allocation
while it runs. Limits are therefore accepted only when the stated number of
concurrent calls can each be granted a largest allocation:
max_concurrent_calls may not exceed max_allocations, and
max_concurrent_calls * max_allocation_bytes may not exceed max_bytes.
Implementations§
Source§impl AllocatorLimits
impl AllocatorLimits
Sourcepub fn configured_max_generations(&self) -> usize
pub fn configured_max_generations(&self) -> usize
Requested maximum number of live policy generations.
Sourcepub fn configured_max_allocations(&self) -> usize
pub fn configured_max_allocations(&self) -> usize
Requested maximum allocation count, including policy calls in progress.
Sourcepub fn configured_max_bytes(&self) -> usize
pub fn configured_max_bytes(&self) -> usize
Requested maximum retained and granted bytes in total.
Sourcepub fn configured_max_concurrent_calls(&self) -> usize
pub fn configured_max_concurrent_calls(&self) -> usize
Requested maximum number of concurrent policy calls.
Sourcepub fn configured_max_allocation_bytes(&self) -> usize
pub fn configured_max_allocation_bytes(&self) -> usize
Requested maximum bytes granted to one allocation.
Sourcepub fn new() -> Self
pub fn new() -> Self
The default limits: 256 generations, 1024 allocations, 1 GiB in total, 16 concurrent calls and 64 MiB per allocation.
Sourcepub fn max_generations(self, value: usize) -> Self
pub fn max_generations(self, value: usize) -> Self
The number of policies that may exist at once. A replaced policy counts until the SDK has freed its last allocation.
Sourcepub fn max_allocations(self, value: usize) -> Self
pub fn max_allocations(self, value: usize) -> Self
The number of allocations the SDK may hold at once, counting the policy calls in progress.
Sourcepub fn max_bytes(self, value: usize) -> Self
pub fn max_bytes(self, value: usize) -> Self
The total bytes the SDK may hold at once, counting what the policy calls in progress have been granted.
Sourcepub fn max_concurrent_calls(self, value: usize) -> Self
pub fn max_concurrent_calls(self, value: usize) -> Self
The number of policy calls that may run at the same time.
Sourcepub fn max_allocation_bytes(self, value: usize) -> Self
pub fn max_allocation_bytes(self, value: usize) -> Self
The largest single allocation, at most MAX_ALLOCATION_BYTES.