{
  "version": "https://jsonfeed.org/version/1",
  "title": "Ian's Digital Garden",
  "home_page_url": "https://blog.ianwwagner.com/",
  "feed_url": "https://blog.ianwwagner.com//tag-linux.json",
  "description": "",
  "items": [
    {
      "id": "https://blog.ianwwagner.com//enomem-with-plenty-to-spare.html",
      "url": "https://blog.ianwwagner.com//enomem-with-plenty-to-spare.html",
      "title": "ENOMEM with Plenty to Spare",
      "content_html": "<p>Last night, something curious happened.\nI was working on a project after syncing in some upstream changes.\nAmong the changes were increased parallel workers for a certain part of the code.\nI was running on a rather beefy server with 24 CPU cores and 128GB of RAM.\n(And no Sam, you can't have it.)</p>\n<p>Almost as soon as this part of the code started running,\nthe program crashed with <code>ENOMEM</code>.\n<code>E</code> as in error and <code>NOMEM</code> as in &quot;there's no more memory.&quot;\nBut I was still seeing roughly <em>half</em> of system memory available!</p>\n<p>Obviously the problem wasn't that I had literally run out of memory.\nIt turned out I was hitting a limit on the number of memory map areas.\nThe Linux kernel has a tunable for this: <a href=\"https://kernel.org/doc/html/latest/admin-guide/sysctl/vm.html#max-map-count\"><code>vm.max_map_count</code></a>.\nThis is set to 65,530 per process by default.\n(Aside: I'm curious why 65,530... that's suspiciously close to 2^16).</p>\n<p>I didn't need to raise it by much, but the program I was running made liberal use of <code>mmap</code>,\nso it end up hitting the limits on systems with a higher core count.</p>\n<p>In the extremely unlikely event that you think you've hit something similar,\nyou can check the current number of maps that a process holds like so:</p>\n<pre class=\"marmite-code\"><code class=\"marmite-code-inner language-shell\"><a-c>#pid=1234</a-c>\n<a-f>wc</a-f> <a-co>-l</a-co> <a-s>&quot;/proc/</a-s><a-o>$</a-o><a-pr>pid</a-pr><a-s>/maps&quot;</a-s></code></pre>\n<p>Of course the process needs to be running in order for this to work,\nso you may want to run it in a loop running up to a crash to identify probable cause.</p>\n<p>Some distros raise the limit above the kernel default.\nYou can check or set yours with the <code>sysctl</code> command.</p>\n",
      "summary": "",
      "date_published": "2026-11-27T00:00:00-00:00",
      "image": "",
      "authors": [
        {
          "name": "Ian Wagner",
          "url": "https://fosstodon.org/@ianthetechie",
          "avatar": "media/avi.jpeg"
        }
      ],
      "tags": [
        "Linux"
      ],
      "language": "en"
    }
  ]
}