{
  "id": 3736029,
  "title": "How to Fix High Memory Usage on a Linux Server",
  "url": "https://urgent.news/2026/08/27/how-to-fix-high-memory-usage-on-a-linux-server",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-08-27T12:47:27.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/opservo/how-to-fix-high-memory-usage-on-a-linux-server-25hh"
  },
  "original_language": "en",
  "account": "Dealing with a Linux server running out of memory can be a common and stressful issue for small teams. It's crucial to understand the difference between high memory usage due to caching and actual memory exhaustion. Here's how to diagnose and resolve high memory usage on a Linux server:\n\n1. Get a clear picture of the memory usage. Run the command `free -h` to see total, used, free, and available memory. Pay attention to the available memory column, which accounts for reclaimable cache and is more useful than the free column. Another command is `vmstat 1 5`, which provides a series of five one-second snapshots, showing swap-in and swap-out activity. Run `cat /proc/meminfo` for a full breakdown of memory usage, including Slab, PageTables, and AnonPages.\n\n2. If swap is being actively used (si/so values above zero consistently), then your server is genuinely memory-constrained, unlike when swap space exists but remains idle. Now, find the processes consuming your RAM by running `ps aux --sort=-%mem | head -20`. This command lists the top 20 processes by memory percentage.\n\n3. Diagnose the root cause of the memory issue. Common causes include memory leaks, misconfigured heap limits, running too many processes, kernel slab cache issues, and large log or data buffers. To check for a memory leak, monitor a specific process's RSS (resident set size) using `watch -n 5 ps -p -o rss=`. For misconfigured heap limits, check the startup flags for Java apps (`-Xmx` for maximum heap size) or Node.js (`--max-old-space-size` for maximum heap size). Use `slabtop` to see if kernel object caches are unusually large.\n\n4. Free memory and reduce pressure if needed, following these steps in order of preference: restart the leaking or bloated process, drop the page cache with `echo 1 /proc/sys/vm/drop_caches`, use `2` to free dentries/inodes, `3` for both. You can also reduce worker counts, such as PHP-FPM `pm.max_children` or Unicorn workers, to reflect your actual RAM budget. Alternatively, increase swap temporarily using a `swapfile` with commands like `fallocate`, `chmod`, `mkswap`, and `swapon`. Adjust `vm.swappiness` to 10 to make the kernel prefer keeping processes in RAM over swapping.\n\n5. Finally, prevent future memory spikes by setting per-process memory limits using `systemd`'s `MemoryMax=` in service unit files or `cgroups`. Add alerts for available memory instead of just used memory, and schedule regular restarts for known-leaky long-running processes. Profile your app under realistic load with tools like Valgrind (C/C++), `memory_profiler` (Python), or `clinic.js` (Node.js) to catch leaks before production. For continuous tracking of per-process memory trends, consider using Opservo, which provides per-process memory tracking, anomalies detection, and alerts.",
  "summary": "Linux server running out of memory? Learn how to diagnose and fix high memory usage with real commands — before it takes down your app. Your app starts slowing down, the OOM killer fires, or your monitoring page turns red — and the culprit is memory. High memory usage on a Linux server is one of the most common production crises for small teams, and it's easy to misread. Linux intentionally uses…",
  "key_points": [
    "Use free -h to see total, used, free, and available memory; focus on available memory column.",
    "Check processes consuming RAM with ps aux --sort=-%mem | head -20 to identify top memory users.",
    "Reduce pressure by restarting leaking processes, dropping page cache, or adjusting worker counts."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}