Documentation
¶
Overview ¶
Package memguard bounds a process's memory: it reads the process's peak resident size and reports when it passes a limit, so a runaway stops small and loud instead of taking the machine (0.10.13's re-embed passed 100 GB).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PeakRSS ¶
func PeakRSS() int64
PeakRSS reports this process's peak resident memory in bytes, or 0 when it cannot be read. getrusage reports ru_maxrss in bytes on macOS and in kilobytes on Linux. A peak, not the current size: a process that has grown past its cap stops, which is what the cap is for.
func Watch ¶
Watch samples rss every interval and calls over once, with the size read, the first time it is above limit. The returned stop ends sampling and waits for the sampler to exit; call it when the watched work is done. Once stop is called, over is not: work that finished is not reported. over must exit the process or return promptly, or stop waits for it. A limit of 0 or less, or a nil rss, turns the watch off.
Types ¶
This section is empty.