Sunday, November 15, 2026SubscribeMastheadAbout
Cali ReporterCalifornia · National · West Coast · Good News

Advertisement

Technology

Understanding Memory Usage on Linux VPS

This article explains how to accurately interpret memory usage on a Linux VPS, focusing on the importance of the 'available' metric and the potential pitfalls of relying on the 'free' column.

Portrait of Benjamin Boyce
Artificial Intelligence & Technology · November 15, 2026
Share

AI-generated editorial illustration from an imagined camera angle.
AI-generated editorial illustration from an imagined camera angle. Source image: dev.to.

Linux fills spare memory with disk cache on purpose, so a low 'free' figure is normal. The number that matters is 'available,' which is the kernel's estimate of how much memory a new program could get without swapping. This is illustrated by the 'free -h' command, which provides an overview of memory usage, including the 'available' column. For example, on a 4 GB VPS, the 'available' memory might be 1.9 GB even if the 'free' memory is only 210 MB. This indicates that the server is not short of memory, as the cache is being used to improve disk read performance (Dev.to, ID: 1). [1]

The 'free' command reads its numbers from '/proc/meminfo,' which includes additional details such as 'MemAvailable,' 'Buffers,' 'Cached,' 'Shmem,' 'SReclaimable,' and 'Dirty.' These metrics provide a more detailed view of memory usage. For instance, 'MemAvailable' accounts for free memory plus the part of the cache that can be dropped, excluding shared memory (Shmem) and dirty pages. This information can be obtained using the command: 'grep -E '^(MemTotal|MemFree|MemAvailable|Buffers|Cached|Shmem|SReclaimable|Dirty|SwapTotal|SwapFree|Committed_AS):' /proc/meminfo' (Dev.to, ID: 1). [1]

To identify which processes are using memory, the 'ps' command can be used to sort processes by resident memory (RSS). For example, the command 'ps -eo pid,user,rss,comm --sort=-rss | head -n 15' lists the top processes by memory usage. Additionally, 'systemd-cgtop -m' can be used to view memory usage per service, as each service runs in its own cgroup on current distributions. This helps quickly determine if a specific service, such as MySQL or PHP-FPM, is consuming a significant amount of memory (Dev.to, ID: 1). [1]

The guide specifically references a 4 GB VPS running WordPress and MySQL, illustrating memory usage with a sample output from the free -h command. In this example, the 'total' memory is 3.8 GiB, with 1.9 GiB used, 210 MiB free, 2.0 GiB in 'buff/cache,' and 1.9 GiB available. The 'available' column is emphasized as the key indicator of usable memory, with the 'free' column showing only the memory that is completely unused. This example is from a server with typical web hosting workloads and highlights how Linux manages memory by using spare capacity for disk caching. [1]

Advertisement

The article mentions that the commands and procedures described work on current versions of Ubuntu, Debian, and AlmaLinux. It also notes that some commands require root access, as indicated by the 'sudo' prefix. For example, to view detailed memory statistics, the user must execute 'grep -E '^(MemTotal|MemFree|MemAvailable|Buffers|Cached|Shmem|SReclaimable|Dirty|SwapTotal|SwapFree|Committed_AS):' /proc/meminfo' with root privileges. This ensures that the memory information is accurate and accessible to the system administrator. [1]

The guide provides specific instructions for logging memory usage over a 24-hour period. Two methods are outlined: using 'vmstat' to collect data every 5 minutes for 289 samples, and running a shell loop that logs the 'MemAvailable' value every 300 seconds. These logs allow the administrator to analyze memory trends and make informed decisions about whether to upgrade, tune, or downsize the server's RAM capacity based on real usage data rather than a single snapshot of memory consumption. [1]

The Dev.to article provides a detailed explanation of memory management in Linux-based VPS environments, particularly focusing on how memory is used and interpreted by tools like free and /proc/meminfo. The guide is specifically tailored for current Ubuntu, Debian, and AlmaLinux distributions, with commands that require root access explicitly marked with sudo. The article begins by addressing a common misconception: that a low 'free' memory value indicates a memory shortage. Instead, it emphasizes the importance of the 'available' column, which reflects how much memory is truly usable by new programs without swapping. The example provided is from a 4 GB VPS running WordPress and MySQL, where the 'available' memory is 1.9 GB despite a 'free' memory value of 210 MB. This indicates that the server is not short on memory, as the kernel is using the spare memory for disk caching to improve performance. The article explains that the 'used' column can be misleading, as its calculation depends on the version of the free command, and that the 'available' column is the most reliable indicator of memory availability. The article also discusses the role of the page cache in Linux, which is used to store file contents in RAM for faster access. It cautions against using the echo 3 > /proc/sys/vm/drop_caches command to clear the cache, as this can slow down the system by forcing the cache to refill. The article further details how to use /proc/meminfo to get more detailed memory statistics, including the MemTotal, MemFree, MemAvailable, Buffers, Cached, Shmem, SReclaimable, Dirty, SwapTotal, SwapFree, and Committed_AS values. These metrics provide a more comprehensive view of memory usage and help in diagnosing memory-related issues. The article also discusses how to identify processes that are using memory, using commands like ps and smem. It explains that RSS (resident set size) can be misleading due to shared memory, and that PSS (proportional set size) provides a more accurate picture. The article then moves on to discuss memory usage per service using systemd, which allows for tracking memory usage by service, including page cache. It also covers checking swap usage and the vm.swappiness parameter, which controls how aggressively the kernel swaps out process memory. The article then explains how to look for OOM-killer events, which occur when the kernel has to kill a process due to memory exhaustion. It provides commands to check the kernel log for OOM events and discusses how to log memory usage over a full day using vmstat or sar. The article concludes by explaining how to interpret the logged data to determine whether more RAM is needed, and highlights that available memory should remain above 25-30% of total memory, with no swapping or OOM events, indicating sufficient RAM. If available memory dips below 10-15% at peaks, with occasional small swapping, it suggests that the server is at the edge of its capacity and may need an upgrade. The article also mentions that a 1-2 GB swap file can act as a buffer but is not a substitute for additional RAM. The article is authored by the team at Bigdomainhost, an Indian hosting provider, and provides practical guidance for VPS users looking to optimize their memory usage and determine when an upgrade is necessary. [1]

The article highlights the specific use of the free -h command, which provides a human-readable format of memory usage. It explains that the 'total' column represents the total amount of RAM the kernel can use, which is slightly less than the plan size because the kernel reserves some memory for itself. The 'used' column indicates memory that is not available to new programs, and its calculation can vary depending on the version of the free command. The 'free' column shows the amount of memory that is doing nothing at all, and on a healthy server, this is usually small. The 'buff/cache' column represents the page cache, plus buffers and reclaimable kernel caches, which are used to store file contents and other data in RAM for faster access. The 'available' column is the key metric, as it represents the kernel's estimate of how much memory a new program could get without swapping. The article provides an example from a 4 GB VPS where the 'available' memory is 1.9 GB, indicating that the server is not short on memory despite a 'free' memory value of 210 MB. The article also explains that newer versions of the free command (such as those found in Ubuntu 24.04 and Debian 12) calculate the 'used' column as total minus available, which can lead to the sum of used, free, and buff/cache exceeding the total. In contrast, older versions like AlmaLinux 9 calculate used as total minus free minus buff/cache, resulting in a smaller figure. The article emphasizes that the 'available' column is the most reliable indicator of memory availability and should be the focus when assessing memory usage. It also discusses the importance of the 'shared' (Shmem) memory, which includes tmpfs files and some database shared memory, and how it is counted in the buff/cache but cannot be dropped. The 'available' column already accounts for this, making it a more accurate measure. The article also mentions 'dirty' pages, which are file data waiting to be written to disk, and how they are counted as available but must be flushed to disk before they can be reused. This means that a server with a lot of dirty memory may free it more slowly. The article then moves on to discuss how to use /proc/meminfo to get more detailed memory statistics, including the MemTotal, MemFree, MemAvailable, Buffers, Cached, Shmem, SReclaimable, Dirty, SwapTotal, SwapFree, and Committed_AS values. These metrics provide a more comprehensive view of memory usage and help in diagnosing memory-related issues. The article also discusses the importance of the 'Committed_AS' value, which represents the amount of memory processes have asked for, which can exceed RAM because Linux allows overcommit. A Committed_AS value above MemTotal is not an error by itself but can indicate potential issues if every process were to use the memory it reserved. The article then explains how to identify processes that are using memory using commands like ps and smem. It discusses the limitations of RSS (resident set size), which can be misleading due to shared memory, and the benefits of using PSS (proportional set size) for a more accurate picture. The article also covers how to use systemd to track memory usage per service, including page cache, and how to check swap usage and the vm.swappiness parameter, which controls how aggressively the kernel swaps out process memory. The article then explains how to look for OOM-killer events, which occur when the kernel has to kill a process due to memory exhaustion, and provides commands to check the kernel log for OOM events. The article concludes by discussing how to log memory usage over a full day using vmstat or sar, and how to interpret the logged data to determine whether more RAM is needed. The article emphasizes that available memory should remain above 25-30% of total memory, with no swapping or OOM events, indicating sufficient RAM. If available memory dips below 10-15% at peaks, with occasional small swapping, it suggests that the server is at the edge of its capacity and may need an upgrade. The article also mentions that a 1-2 GB swap file can act as a buffer but is not a substitute for additional RAM. The article is authored by the team at Bigdomainhost, an Indian hosting provider, and provides practical guidance for VPS users looking to optimize their memory usage and determine when an upgrade is necessary. [1]

Advertisement

Sources

Dev.to

Prepared with AI assistance from the cited sources.

The Cali Reporter newsletter

The stories worth your time.

California, the country, and what comes next. Join our free newsletter for reporting that keeps you informed.

By joining, you agree to receive the Cali Reporter newsletter. Unsubscribe at any time. Privacy policy.

More in Technology

Advertisement