cd /news/ai-agents/ai-agents-consume-all-your-memory-in… · home topics ai-agents article
[ARTICLE · art-134252] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

AI agents consume all your memory in linux by default

A developer traced repeated freezes on a 64 GB Linux workstation to roughly 22 GB of agent-created files accumulating in a tmpfs-backed /tmp, where contents live in RAM or swap and cannot be discarded like ordinary disk cache. The writeup recommends diagnosing the mount with findmnt, df and du, then either redirecting agents to a disk-backed directory via TMPDIR or masking systemd's tmp.mount so /tmp falls back to the root filesystem. The author notes the behavior is not unique to AI workloads, since compilers such as GCC also create temporary intermediate files, but parallel coding agents made the memory trade-off visible.

by read3 min views1 publishedSep 19, 2026

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.

Linux kernel: Tmpfs. ↩

Ubuntu: Data Driven Analysis — /tmp on tmpfs. ↩

systemd: Using /tmp/ and /var/tmp/ Safely. ↩

GCC: Environment Variables. ↩

findmnt(8). ↩

df(1). ↩

du(1). ↩

free(1). ↩

mkdir(1). ↩

chmod(1). ↩

systemctl(1). ↩

systemd: upstream tmp.mount. ↩

Apple: File System Basics. ↩

Microsoft: GetTempPath2. ↩

Microsoft: File Caching. ↩

── more in #ai-agents 4 stories · sorted by recency
── more on @linux 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/ai-agents-consume-al…] indexed:0 read:3min 2026-09-19 ·