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.
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.<sup>1</sup>
Memory-backed temporary storage can offer fast I/O, fewer storage writes, and cleanup on reboot. But swapping can undermine those benefits.<sup>2</sup>
The distinction is workload size. Systemd recommends /tmp for small, bounded files and /var/tmp for larger data.<sup>3</sup> This is not uniquely an AI problem: GCC also creates temporary intermediate files.<sup>4</sup> Parallel agent work simply made the trade-off visible on my machine.
Run these in a Linux terminal:
findmnt -T /tmp -o TARGET,SOURCE,FSTYPE
df -hT /tmp
sudo du -x -h --max-depth=1 /tmp | sort -h
free -h
Look for tmpfs under FSTYPE. Keep -T: plain findmnt /tmp can return nothing when /tmp is not a separate mount.<sup>5</sup>
df measures the containing filesystem; du measures the directory tree.<sup>6</sup><sup>7</sup> In free, focus on available.<sup>8</sup> Large tmpfs usage alongside low available memory deserves investigation—not automatic blame for every crash.
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.<sup>9</sup><sup>10</sup> 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.<sup>3</sup>
Verify the path and filesystem inside the agent’s actual execution environment, especially with containers or sandboxes.<sup>5</sup> Clean up completed scratch data yourself; this directory does not inherit /tmp’s cleanup policy.<sup>3</sup>
/tmp disk-backed system-wide
For systemd-based distributions, inspect first:
systemctl cat tmp.mount --no-pager
findmnt --fstab --mountpoint /tmp
findmnt -T / -o TARGET,SOURCE,FSTYPE,OPTIONS
df -hT /
tmp.mount is one name, with a dot.<sup>11</sup>
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.<sup>5</sup><sup>11</sup>
sudo systemctl mask tmp.mount
This prevents future activation without unmounting the current /tmp.<sup>11</sup> Save your work, copy anything needed out of /tmp, then reboot when ready. Existing tmpfs files disappear; they do not migrate to disk.<sup>1</sup>
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.<sup>11</sup>
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.<sup>12</sup><sup>3</sup>
Native macOS and Windows normally use disk-backed temporary directories, so large temporary trees primarily consume disk space.<sup>13</sup><sup>14</sup> They can still exhaust memory; disk-backed does not mean cache-free.<sup>15</sup> For Linux containers or virtual machines, check inside that environment.<sup>5</sup>
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.
Ubuntu: Data Driven Analysis — /tmp on tmpfs. ↩
systemd: Using /tmp/ and /var/tmp/ Safely. ↩
findmnt(8). ↩
df(1). ↩
du(1). ↩
free(1). ↩
mkdir(1). ↩
chmod(1). ↩
systemctl(1). ↩
systemd: upstream tmp.mount. ↩