My 64 GB Linux workstation kept freezing while coding agents worked on a couple of projects. All 4 GB of swap filled up. Applications were killed. Half the memory looked like cache.
Then I found 22 GB of agent-created files in a tmpfs-backed /tmp.
Not all cache is disposable
tmpfs stores file contents in RAM or swap. Unlike clean disk-backed cache, those contents cannot simply be discarded. Some memory monitors include tmpfs in cache-related accounting, making the memory pressure easy to misread.1
Memory-backed temporary storage can offer fast I/O, fewer storage writes, and cleanup on reboot. But swapping can undermine those benefits.2
The distinction is workload size. Systemd recommends /tmp for small, bounded files and /var/tmp for larger data.3 This is not uniquely an AI problem: GCC also creates temporary intermediate files.4 Parallel agent work simply made the trade-off visible on my machine.
Check your machine
Run these in a Linux terminal:
# Filesystem containing /tmp
findmnt -T /tmp -o TARGET,SOURCE,FSTYPE
# Capacity and usage of that filesystem
df -hT /tmp
# Directory sizes, largest last; stay on one filesystem
sudo du -x -h --max-depth=1 /tmp | sort -h
# RAM and swap usage
free -h
Look for tmpfs under FSTYPE. Keep -T: plain findmnt /tmp can return nothing when /tmp is not a separate mount.5
df measures the containing filesystem; du measures the directory tree.67 In free, focus on available.8 Large tmpfs usage alongside low available memory deserves investigation—not automatic blame for every crash.
Option 1: redirect heavy workloads
Create a private directory and check its filesystem and free space:
mkdir -p "$HOME/.local/tmp"
chmod 700 "$HOME/.local/tmp"
findmnt -T "$HOME/.local/tmp" -o TARGET,SOURCE,FSTYPE
df -hT "$HOME/.local/tmp"
mkdir -p creates missing directories; chmod 700 restricts ordinary access to the owner.910 Confirm the directory is disk-backed before proceeding.
export TMPDIR="$HOME/.local/tmp"
Launch your agent from that same terminal. Programs honoring TMPDIR can use the new location. Hard-coded /tmp paths and existing workspaces need separate changes.3
Verify the path and filesystem inside the agent’s actual execution environment, especially with containers or sandboxes.5 Clean up completed scratch data yourself; this directory does not inherit /tmp’s cleanup policy.3
Option 2: make /tmp disk-backed system-wide
For systemd-based distributions, inspect first:
# Mount unit and any overrides
systemctl cat tmp.mount --no-pager
# Explicit /tmp configuration; no output means no matching entry
findmnt --fstab --mountpoint /tmp
# Root filesystem, mount options, and free space
findmnt -T / -o TARGET,SOURCE,FSTYPE,OPTIONS
df -hT /
tmp.mount is one name, with a dot.11
Use the following only when /tmp is tmpfs, its unit is distribution-provided with no local customizations, /etc/fstab has no /tmp entry, and / is writable, disk-backed, and has adequate space. Otherwise, use Option 1 rather than forcing this shortcut.511
sudo systemctl mask tmp.mount
This prevents future activation without unmounting the current /tmp.11 Save your work, copy anything needed out of /tmp, then reboot when ready. Existing tmpfs files disappear; they do not migrate to disk.1
After reboot, verify:
findmnt -T /tmp -o TARGET,SOURCE,FSTYPE
/tmp should now belong to the disk-backed root filesystem. To reverse the mask, run sudo systemctl unmask tmp.mount, then reboot.11
This trades memory-backed storage for root-disk usage and can remove mount-specific restrictions such as nosuid,nodev. Disk space, cleanup, and security policy still matter.123
Why macOS and Windows usually avoid this trap
Native macOS and Windows normally use disk-backed temporary directories, so large temporary trees primarily consume disk space.1314 They can still exhaust memory; disk-backed does not mean cache-free.15 For Linux containers or virtual machines, check inside that environment.5
The takeaway
This is not a reason to disable tmpfs everywhere. It is a reason to put multi-gigabyte workspaces on storage chosen deliberately.
“Temporary” describes how long data is needed—not where it belongs.
Top comments (0)