Resource Limits
In this article
- Set wall-time, memory, scratch-disk and process limits on a sandbox container from outside the code it runs.
- Predict which limit ends an endless loop, a huge allocation, a fork bomb and a disk fill, and read the exit cause from the container state and the program's error.
- Explain why a CPU limit cannot replace wall time, and why the runner kills the whole container so no child process survives.
- Terms defined here: resource limit, timeout.
Overview
An AI agent writes code and you run it. One day that code loops forever, or asks for ten gigabytes of memory, or copies itself until no process slots are left, or writes until the disk is full. What stops each of these, and when the run ends, how do you know which one happened?
You will put four limits on a container, an isolated box on your machine for one run of the code, predict how four misbehaving programs end, run them, and read each exit cause from the container itself. You will also see why only the clock ends a loop, and what to kill so no process is left behind.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- Who stops the code
- Four limits on one line
- Predict, then run
- Reading the report
- Why only the clock ends a loop
- Kill the container, not the client
- The rule at work
- Common mistakes
- In production
- Sources
- Check yourself, 13 questions