<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Leanid Piliptsevich</title>
    <description>The latest articles on DEV Community by Leanid Piliptsevich (@leanid_piliptsevich_7c592).</description>
    <link>https://dev.to/leanid_piliptsevich_7c592</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4122684%2F373f58ec-523c-4ab8-9397-8a8aefeb9a47.jpg</url>
      <title>DEV Community: Leanid Piliptsevich</title>
      <link>https://dev.to/leanid_piliptsevich_7c592</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/leanid_piliptsevich_7c592"/>
    <language>en</language>
    <item>
      <title>AI agents consume all your memory in linux by default</title>
      <dc:creator>Leanid Piliptsevich</dc:creator>
      <pubDate>Sat, 19 Sep 2026 00:10:27 +0000</pubDate>
      <link>https://dev.to/leanid_piliptsevich_7c592/ai-agents-consume-all-your-memory-in-linux-by-default-47ph</link>
      <guid>https://dev.to/leanid_piliptsevich_7c592/ai-agents-consume-all-your-memory-in-linux-by-default-47ph</guid>
      <description>&lt;p&gt;My &lt;strong&gt;64 GB Linux workstation&lt;/strong&gt; 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.&lt;/p&gt;

&lt;p&gt;Then I found &lt;strong&gt;22 GB of agent-created files in a tmpfs-backed &lt;code&gt;/tmp&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Not all cache is disposable
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;tmpfs&lt;/code&gt; stores file contents in &lt;strong&gt;RAM or swap&lt;/strong&gt;. 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.&lt;sup id="fnref1"&gt;1&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;Memory-backed temporary storage can offer fast I/O, fewer storage writes, and cleanup on reboot. But swapping can undermine those benefits.&lt;sup id="fnref2"&gt;2&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;The distinction is workload size. Systemd recommends &lt;code&gt;/tmp&lt;/code&gt; for &lt;strong&gt;small, bounded files&lt;/strong&gt; and &lt;code&gt;/var/tmp&lt;/code&gt; for larger data.&lt;sup id="fnref3"&gt;3&lt;/sup&gt; This is not uniquely an AI problem: GCC also creates temporary intermediate files.&lt;sup id="fnref4"&gt;4&lt;/sup&gt; Parallel agent work simply made the trade-off visible on my machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check your machine
&lt;/h2&gt;

&lt;p&gt;Run these in a Linux terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Filesystem containing /tmp&lt;/span&gt;
findmnt &lt;span class="nt"&gt;-T&lt;/span&gt; /tmp &lt;span class="nt"&gt;-o&lt;/span&gt; TARGET,SOURCE,FSTYPE

&lt;span class="c"&gt;# Capacity and usage of that filesystem&lt;/span&gt;
&lt;span class="nb"&gt;df&lt;/span&gt; &lt;span class="nt"&gt;-hT&lt;/span&gt; /tmp

&lt;span class="c"&gt;# Directory sizes, largest last; stay on one filesystem&lt;/span&gt;
&lt;span class="nb"&gt;sudo du&lt;/span&gt; &lt;span class="nt"&gt;-x&lt;/span&gt; &lt;span class="nt"&gt;-h&lt;/span&gt; &lt;span class="nt"&gt;--max-depth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 /tmp | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-h&lt;/span&gt;

&lt;span class="c"&gt;# RAM and swap usage&lt;/span&gt;
free &lt;span class="nt"&gt;-h&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look for &lt;code&gt;tmpfs&lt;/code&gt; under &lt;code&gt;FSTYPE&lt;/code&gt;. Keep &lt;code&gt;-T&lt;/code&gt;: plain &lt;code&gt;findmnt /tmp&lt;/code&gt; can return nothing when &lt;code&gt;/tmp&lt;/code&gt; is not a separate mount.&lt;sup id="fnref5"&gt;5&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;df&lt;/code&gt; measures the containing filesystem; &lt;code&gt;du&lt;/code&gt; measures the directory tree.&lt;sup id="fnref6"&gt;6&lt;/sup&gt;&lt;sup id="fnref7"&gt;7&lt;/sup&gt; In &lt;code&gt;free&lt;/code&gt;, focus on &lt;strong&gt;&lt;code&gt;available&lt;/code&gt;&lt;/strong&gt;.&lt;sup id="fnref8"&gt;8&lt;/sup&gt; Large tmpfs usage alongside low available memory deserves investigation—not automatic blame for every crash.&lt;/p&gt;

&lt;h2&gt;
  
  
  Option 1: redirect heavy workloads
&lt;/h2&gt;

&lt;p&gt;Create a private directory and check its filesystem and free space:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.local/tmp"&lt;/span&gt;
&lt;span class="nb"&gt;chmod &lt;/span&gt;700 &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.local/tmp"&lt;/span&gt;
findmnt &lt;span class="nt"&gt;-T&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.local/tmp"&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; TARGET,SOURCE,FSTYPE
&lt;span class="nb"&gt;df&lt;/span&gt; &lt;span class="nt"&gt;-hT&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.local/tmp"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;mkdir -p&lt;/code&gt; creates missing directories; &lt;code&gt;chmod 700&lt;/code&gt; restricts ordinary access to the owner.&lt;sup id="fnref9"&gt;9&lt;/sup&gt;&lt;sup id="fnref10"&gt;10&lt;/sup&gt; Confirm the directory is disk-backed before proceeding.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;TMPDIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.local/tmp"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Launch your agent from that same terminal.&lt;/strong&gt; Programs honoring &lt;code&gt;TMPDIR&lt;/code&gt; can use the new location. Hard-coded &lt;code&gt;/tmp&lt;/code&gt; paths and existing workspaces need separate changes.&lt;sup id="fnref3"&gt;3&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;Verify the path and filesystem &lt;strong&gt;inside the agent’s actual execution environment&lt;/strong&gt;, especially with containers or sandboxes.&lt;sup id="fnref5"&gt;5&lt;/sup&gt; Clean up completed scratch data yourself; this directory does not inherit &lt;code&gt;/tmp&lt;/code&gt;’s cleanup policy.&lt;sup id="fnref3"&gt;3&lt;/sup&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Option 2: make &lt;code&gt;/tmp&lt;/code&gt; disk-backed system-wide
&lt;/h2&gt;

&lt;p&gt;For systemd-based distributions, inspect first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Mount unit and any overrides&lt;/span&gt;
systemctl &lt;span class="nb"&gt;cat &lt;/span&gt;tmp.mount &lt;span class="nt"&gt;--no-pager&lt;/span&gt;

&lt;span class="c"&gt;# Explicit /tmp configuration; no output means no matching entry&lt;/span&gt;
findmnt &lt;span class="nt"&gt;--fstab&lt;/span&gt; &lt;span class="nt"&gt;--mountpoint&lt;/span&gt; /tmp

&lt;span class="c"&gt;# Root filesystem, mount options, and free space&lt;/span&gt;
findmnt &lt;span class="nt"&gt;-T&lt;/span&gt; / &lt;span class="nt"&gt;-o&lt;/span&gt; TARGET,SOURCE,FSTYPE,OPTIONS
&lt;span class="nb"&gt;df&lt;/span&gt; &lt;span class="nt"&gt;-hT&lt;/span&gt; /
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;tmp.mount&lt;/code&gt; is one name, with a dot.&lt;/strong&gt;&lt;sup id="fnref11"&gt;11&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;Use the following only when &lt;code&gt;/tmp&lt;/code&gt; is tmpfs, its unit is distribution-provided with no local customizations, &lt;code&gt;/etc/fstab&lt;/code&gt; has no &lt;code&gt;/tmp&lt;/code&gt; entry, and &lt;code&gt;/&lt;/code&gt; is writable, disk-backed, and has adequate space. Otherwise, use Option 1 rather than forcing this shortcut.&lt;sup id="fnref5"&gt;5&lt;/sup&gt;&lt;sup id="fnref11"&gt;11&lt;/sup&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl mask tmp.mount
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prevents future activation without unmounting the current &lt;code&gt;/tmp&lt;/code&gt;.&lt;sup id="fnref11"&gt;11&lt;/sup&gt; &lt;strong&gt;Save your work, copy anything needed out of &lt;code&gt;/tmp&lt;/code&gt;, then reboot when ready. Existing tmpfs files disappear; they do not migrate to disk.&lt;/strong&gt;&lt;sup id="fnref1"&gt;1&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;After reboot, verify:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;findmnt &lt;span class="nt"&gt;-T&lt;/span&gt; /tmp &lt;span class="nt"&gt;-o&lt;/span&gt; TARGET,SOURCE,FSTYPE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;/tmp&lt;/code&gt; should now belong to the disk-backed root filesystem. To reverse the mask, run &lt;code&gt;sudo systemctl unmask tmp.mount&lt;/code&gt;, then reboot.&lt;sup id="fnref11"&gt;11&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;This trades memory-backed storage for root-disk usage and can remove mount-specific restrictions such as &lt;code&gt;nosuid,nodev&lt;/code&gt;. Disk space, cleanup, and security policy still matter.&lt;sup id="fnref12"&gt;12&lt;/sup&gt;&lt;sup id="fnref3"&gt;3&lt;/sup&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why macOS and Windows usually avoid this trap
&lt;/h2&gt;

&lt;p&gt;Native macOS and Windows normally use &lt;strong&gt;disk-backed temporary directories&lt;/strong&gt;, so large temporary trees primarily consume disk space.&lt;sup id="fnref13"&gt;13&lt;/sup&gt;&lt;sup id="fnref14"&gt;14&lt;/sup&gt; They can still exhaust memory; disk-backed does not mean cache-free.&lt;sup id="fnref15"&gt;15&lt;/sup&gt; For Linux containers or virtual machines, check inside that environment.&lt;sup id="fnref5"&gt;5&lt;/sup&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;p&gt;This is not a reason to disable tmpfs everywhere. It is a reason to put multi-gigabyte workspaces on storage chosen deliberately.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;“Temporary” describes how long data is needed—not where it belongs.&lt;/strong&gt;&lt;/p&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;&lt;a href="https://www.kernel.org/doc/html/latest/filesystems/tmpfs.html" rel="noopener noreferrer"&gt;Linux kernel: Tmpfs&lt;/a&gt;.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn2"&gt;
&lt;p&gt;&lt;a href="https://ubuntu.com/blog/data-driven-analysis-tmp-on-tmpfs" rel="noopener noreferrer"&gt;Ubuntu: Data Driven Analysis — /tmp on tmpfs&lt;/a&gt;.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn3"&gt;
&lt;p&gt;&lt;a href="https://systemd.io/TEMPORARY_DIRECTORIES/" rel="noopener noreferrer"&gt;systemd: Using /tmp/ and /var/tmp/ Safely&lt;/a&gt;.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn4"&gt;
&lt;p&gt;&lt;a href="https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html" rel="noopener noreferrer"&gt;GCC: Environment Variables&lt;/a&gt;.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn5"&gt;
&lt;p&gt;&lt;a href="https://man7.org/linux/man-pages/man8/findmnt.8.html" rel="noopener noreferrer"&gt;findmnt(8)&lt;/a&gt;.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn6"&gt;
&lt;p&gt;&lt;a href="https://man7.org/linux/man-pages/man1/df.1.html" rel="noopener noreferrer"&gt;df(1)&lt;/a&gt;.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn7"&gt;
&lt;p&gt;&lt;a href="https://man7.org/linux/man-pages/man1/du.1.html" rel="noopener noreferrer"&gt;du(1)&lt;/a&gt;.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn8"&gt;
&lt;p&gt;&lt;a href="https://man7.org/linux/man-pages/man1/free.1.html" rel="noopener noreferrer"&gt;free(1)&lt;/a&gt;.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn9"&gt;
&lt;p&gt;&lt;a href="https://man7.org/linux/man-pages/man1/mkdir.1.html" rel="noopener noreferrer"&gt;mkdir(1)&lt;/a&gt;.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn10"&gt;
&lt;p&gt;&lt;a href="https://man7.org/linux/man-pages/man1/chmod.1.html" rel="noopener noreferrer"&gt;chmod(1)&lt;/a&gt;.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn11"&gt;
&lt;p&gt;&lt;a href="https://man7.org/linux/man-pages/man1/systemctl.1.html" rel="noopener noreferrer"&gt;systemctl(1)&lt;/a&gt;.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn12"&gt;
&lt;p&gt;&lt;a href="https://raw.githubusercontent.com/systemd/systemd/main/units/tmp.mount" rel="noopener noreferrer"&gt;systemd: upstream tmp.mount&lt;/a&gt;.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn13"&gt;
&lt;p&gt;&lt;a href="https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html" rel="noopener noreferrer"&gt;Apple: File System Basics&lt;/a&gt;.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn14"&gt;
&lt;p&gt;&lt;a href="https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2a" rel="noopener noreferrer"&gt;Microsoft: GetTempPath2&lt;/a&gt;.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn15"&gt;
&lt;p&gt;&lt;a href="https://learn.microsoft.com/en-us/windows/win32/fileio/file-caching" rel="noopener noreferrer"&gt;Microsoft: File Caching&lt;/a&gt;.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>agents</category>
      <category>linux</category>
      <category>ai</category>
      <category>memory</category>
    </item>
  </channel>
</rss>
