Logo ProcessKit API Reference

ResourceLimits Type

Resource limits enforced on a process group **as a whole** (not per process), applied to the kernel container at creation time. Enforcement needs a real container — a **Windows Job Object** or a **Linux cgroup v2**. On macOS and the Linux process-group fallback there is no whole-tree limit primitive, so requesting *any* limit there fails fast with `ProcessError.ResourceLimit` rather than silently leaving the tree unbounded. On Linux the cgroup v2 controllers can only be enabled when this process runs at the real cgroup-v2 hierarchy root (not under a systemd scope, nor in an ordinary container); when they cannot, group creation fails fast for the same reason.

Instance members

Instance member Description

this.CpuQuota

Full Usage: this.CpuQuota

Returns: float option

CPU quota as a fraction of a single core (`0.5` = half a core, `2.0` = two cores). `None` leaves CPU unbounded. On Windows this is approximate (converted against the host core count).

Returns: float option

this.MaxProcesses

Full Usage: this.MaxProcesses

Returns: int option

Maximum number of live processes in the tree. `None` leaves the count unbounded.

Returns: int option

this.MemoryMax

Full Usage: this.MemoryMax

Returns: int64 option

Maximum total memory for the tree, in bytes. `None` leaves memory unbounded.

Returns: int64 option

this.WithCpuQuota

Full Usage: this.WithCpuQuota

Parameters:
    cores : float

Returns: ResourceLimits

A copy with the CPU quota (in cores) set. `cores` must be a finite, strictly positive number — zero, negative, `NaN`, or `PositiveInfinity`/`NegativeInfinity` is rejected (`ArgumentOutOfRangeException`): a non-positive quota could never let anything run, and an infinite one has no meaningful cgroup encoding. Also rejected: a value whose conversion into a cgroup v2 `cpu.max` "quota period" string (see `Native.Cgroup.cpuMaxValue`) would overflow `int64` once rounded to microseconds — the same math is mirrored here (rather than called into `Native.Cgroup`, which compiles after `Limits.fs`) so the rejection is identical on every platform, before a `ProcessGroup` is even created, instead of only surfacing later and only on the Linux backend.

cores : float
Returns: ResourceLimits

this.WithMaxProcesses

Full Usage: this.WithMaxProcesses

Parameters:
    count : int

Returns: ResourceLimits

A copy with the live-process cap set. `count` must be positive — zero or negative is rejected (`ArgumentOutOfRangeException`): the tree always has at least its own leader process, so a non-positive cap could never be satisfied.

count : int
Returns: ResourceLimits

this.WithMemoryMax

Full Usage: this.WithMemoryMax

Parameters:
    bytes : int64

Returns: ResourceLimits

A copy with the memory cap set. `bytes` must be positive — zero or negative is rejected (`ArgumentOutOfRangeException`): a non-positive cap could never let anything run, so it is a misconfiguration rather than a meaningful limit, and previously degraded silently (e.g. a negative value converting to a huge `unativeint` on Windows — effectively "unlimited").

bytes : int64
Returns: ResourceLimits

Static members

Static member Description

ResourceLimits.None

Full Usage: ResourceLimits.None

Returns: ResourceLimits

No limits — the default.

Returns: ResourceLimits

Type something to start searching.