Skip to main content

snapshot

Function snapshot 

Source
pub fn snapshot(
    record_bytes: u64,
    command_limits: OutputLimits,
) -> Result<Snapshot, SamplingError>
Expand description

Observe process leaders using Linux /proc or the macOS native ps table.

record_bytes bounds each complete Linux stat record; oversized records refuse before parsing, even if a retained prefix contains plausible numeric fields. Consumers own sampling cadence, workload selection and total snapshot memory. command_limits selects macOS stdout/stderr retention and an optional capture deadline; timeout: None imposes no elapsed-time deadline. Linux does not use command_limits, and macOS does not use record_bytes. Processes that disappear or deny stat access during Linux enumeration are skipped. macOS ps RSS uses 1024-byte units, independently of native memory page size. The native command’s stderr is captured rather than printed. Failed captures retain bounded output and cleanup evidence in SamplingError::Command. Successful but truncated output refuses before parsing, even if the retained prefix contains complete rows. This is not a bound on total parsed table memory.

§Errors

Returns native I/O, capture/exit/truncation, malformed-record or checked-arithmetic failures. macOS uses the direct-child capture engine; deadlines and cleanup have that engine’s documented synchronous syscall and reaping limitations.