How to check memory usage

Topic: Servers linux

Summary

Use free, /proc/meminfo, and top or smem to see total RAM, used, free, buffers, cache, and swap. Identify processes by RSS or VSZ. Use this when diagnosing high memory use, before adding swap, or when tuning application memory limits.

Intent: How-to

Quick answer

  • free -h shows total, used, free, shared, buff/cache, available. Available is what apps can use without reclaiming; used does not include reclaimable cache, so prefer available for 'how much headroom'.
  • top or htop: sort by MEM% or RES; ps -eo pid,rss,vsz,cmd --sort=-rss | head. RSS is physical memory; VSZ is virtual. smem gives PSS for a better per-process view.
  • Check /proc/meminfo for detail; watch -n 2 free -h to see change over time. If available is low and swap is growing, see OOM and add-swap guides.

Prerequisites

Steps

  1. Summary with free

    free -h; note Mem available (not just free). Linux uses free RAM for cache; available = free + reclaimable cache. Swap line shows swap use; if swap is filling, memory pressure is high.

  2. Per-process memory

    top, then M to sort by memory; or ps -eo pid,rss,vsz,cmd --sort=-rss | head -20. RSS is resident set (physical); use smem for PSS if installed. Identify the process(es) using the most RAM.

  3. Interpret and act

    If available is consistently low, consider adding swap or tuning the app; if a single process grows without bound, fix the app or restart it. See OOM guide if the kernel is killing processes.

Summary

Use free for system-wide memory and available headroom; use top, ps, or smem for per-process usage. Use this to find what is using RAM and to decide whether to add swap or tune applications.

Prerequisites

Steps

Step 1: Summary with free

free -h

Focus on “available” and swap use.

Step 2: Per-process memory

ps -eo pid,rss,vsz,cmd --sort=-rss | head -20

Or use top (M to sort by memory).

Step 3: Interpret and act

If available is low, add swap or tune the app; if one process grows unbounded, fix or restart it. See OOM guide if processes are being killed.

Verification

  • You know total RAM, available, swap use, and which processes use the most memory.

Troubleshooting

available very low — Add swap or reduce workload; see Add swap and OOM. Cache high — Normal; Linux uses free RAM for cache; it is reclaimable.

Next steps

Continue to