Payments are experiencing issues due to temporary restrictions in Russia. If your payment does not go through, please submit a support request.Our support team is available 24/7 — we are always here to help with hosting and server issues.We are now accepting requests for dedicated server rental and colocation services in our data center.Reminder: we recommend enabling backups for additional data protection.A new VPS/VDS lineup with NVMe storage and improved performance is now available.Maintenance work on some servers has been completed. All services are operating normally.
Article3 min readViews0

How to Distinguish Memory Shortage from Standard Linux Cache

Check available memory and swap usage with free and vmstat to avoid mistaking useful file cache for a leak.

RAM modules on the server motherboard
In this article

In the dashboard, almost all RAM appears occupied, yet the site runs normally. Or conversely: free megabytes are still visible, but requests have slowed down. A single number is insufficient. Linux uses part of the memory for cache, so signs of real pressure must be found in available memory and system behavior over time.

State Snapshot

These commands are designed for Linux with the procps package. They do not change memory settings. In a container, the readings may not describe all application constraints: the container limit must be checked separately in its management environment.

free -h

First, examine available. This is the memory estimate available to applications without triggering swapping. The field free shows unused pages and does not account for the full potential of cache release. Therefore, a small value of free is not a standalone reason to restart.

Also record the swap volume and its usage status. Non-zero swap does not prove that the system is actively swapping pages to disk right now: some rarely used pages may have been moved there earlier.

Observe the movement

For a short series of observations, run:

vmstat 1 6

Six reports will be output at one-second intervals. The first line contains load-averaged activity metrics; for the current interval, refer to the following lines. Memory fields reflect the current state, so the entire first line cannot be described by a single average value.

The columns si and so help reveal page inflow from and outflow to swap. Compare them with available memory, application latency, and disk activity. A single short spike and sustained swapping throughout an incident require different conclusions.

Two different examples

If sufficient memory is available, swap usage remains minimal and site responses are fast; a filled file cache does not require intervention on its own. Forcing a cache clear can worsen the situation, as data must then be read from disk again.

If available memory drops, swap activity persists and users simultaneously notice delays, making the hypothesis of memory shortage more likely. The next step is to identify which processes are growing and which jobs started before the issue. For example, a nightly backup might coincide with a catalog import, increasing total consumption.

Quick check map

Metric

What it helps understand

What it does not prove

available

Estimate of memory available to applications

Absence of a container limit

Used swap

Presence of swapped-out pages

Active swapping at this moment

si and so

Page movement within the interval

Reason for the increase in consumption by a specific application

What to check in the application

Distinguish between the server's total memory and a specific process's limit. An application may terminate due to its own limit even if system memory is free. The reverse situation is also possible: each process appears moderate, but their number has grown, causing total consumption to become excessive.

Save the measurement time, output from both commands, the number of concurrently running tasks, and the observed latency. Do not conclude a memory leak based on a single snapshot; dynamics under comparable load are essential. After applying a fix, repeat a short observation during the same working period.

Do not disable swap or change kernel parameters as a first step. First, confirm the scenario: which resource is constrained, when it occurs, and which process generates the load. Only then can the solution be validated by the result, not by a changed graph color.

Discussion 0

Share your experience and ask questions. Comments without links appear after editorial review.

No comments yet. Start the discussion.