pub struct ProcessMemoryLimit { /* private fields */ }Expand description
Represents process memory limit.
Implementations§
Source§impl ProcessMemoryLimit
impl ProcessMemoryLimit
Sourcepub fn detect() -> RuntimeResult<Self>
pub fn detect() -> RuntimeResult<Self>
Detects the effective process memory limit.
§Errors
Returns an operational error when process, cgroup, or environment discovery cannot provide a finite limit.
Sourcepub fn detect_with_view(view: &dyn MemoryFileView) -> RuntimeResult<Self>
pub fn detect_with_view(view: &dyn MemoryFileView) -> RuntimeResult<Self>
Detects the effective process memory limit through an injectable file view.
The explicit environment override wins. Otherwise the cgroup membership
and mounts are read from the view when the platform uses them, and the
smallest finite hard limit wins over the host physical memory fallback.
A HostPhysicalMemory source on Linux means no finite cgroup hard limit
was visible from this process’s membership, so the kernel may enforce a
tighter constraint than the reported one.
§Errors
Returns a configuration error when the explicit environment value is not a positive byte count, and an operational error when the view cannot read a file that exists or when no finite constraint is discoverable.
Sourcepub fn configured(bytes: u64) -> Result<Self, RuntimeContractViolation>
pub fn configured(bytes: u64) -> Result<Self, RuntimeContractViolation>
Creates an explicitly configured process memory limit.
§Errors
Returns a contract violation when bytes is zero.
Sourcepub const fn source(self) -> MemoryLimitSource
pub const fn source(self) -> MemoryLimitSource
Returns the source.