A Linux host can look short on memory when much of the used value is reclaimable cache rather than application pressure. Clear memory only after checking available memory, cache, and swap so a one-time reclaim does not hide a process leak or slow the next disk-heavy workload.
The kernel reclaims page cache and many slab objects automatically when applications need memory. The /proc/sys/vm/drop_caches sysctl is a manual, one-shot request to discard clean page cache, dentries, and inodes; running sync first writes dirty data so more cached objects are eligible.
Use cache dropping for testing, recovery after a known cache-heavy job, or a controlled maintenance action, not as a recurring scheduler task. If available remains low after caches are dropped, or swap-in activity continues, investigate memory pressure and process resident memory instead of repeating the same cleanup.
Related: How to check memory usage in Linux
Related: How to check swap memory usage in Linux
$ free -h
total used free shared buff/cache available
Mem: 11Gi 883Mi 7.9Gi 29Mi 3.1Gi 10Gi
Swap: 4.0Gi 512Mi 3.5Gi
available estimates how much memory can be used by new applications without swapping. buff/cache is the cache and buffer total that may shrink after a cache drop.
$ sudo sync
drop_caches discards clean cached objects only, so syncing first gives the kernel more clean cache candidates.
$ sudo sysctl -w vm.drop_caches=3 vm.drop_caches = 3
vm.drop_caches=3 discards reclaimable cache but does not fix a memory leak. It can make the next file reads slower while the kernel rebuilds cache from disk.
$ free -h
total used free shared buff/cache available
Mem: 11Gi 871Mi 10Gi 29Mi 942Mi 10Gi
Swap: 4.0Gi 512Mi 3.5Gi
A lower buff/cache value and higher free value confirm that clean caches were reclaimed. If available is still low, cache was not the main constraint.
$ swapon --show NAME TYPE SIZE USED PRIO /var/lib/swap file 4G 512M -2
If no rows appear or USED is 0B, skip the swap refresh steps.
$ sudo swapoff -a
swapoff -a moves swapped pages back into memory and can trigger out-of-memory kills when available is too low for the USED swap amount.
$ sudo swapon -a
swapon -a enables swap entries from /etc/fstab unless an entry is marked with noauto.
$ swapon --show NAME TYPE SIZE USED PRIO /var/lib/swap file 4G 0B -2
The USED value returning to 0B shows that the previous swap contents were cleared.
$ cat /proc/pressure/memory some avg10=0.00 avg60=0.00 avg300=0.00 total=124503 full avg10=0.00 avg60=0.00 avg300=0.00 total=0
Sustained non-zero some or full pressure after cache and swap cleanup points to workload sizing, cgroup limits, or memory-heavy processes.
Related: How to check memory pressure in Linux
Related: How to check process CPU and memory usage in Linux