Hostxpeed
Login Get Started →
Getting Started

How to Check Memory Usage

5 min read
25 views
Jun 12, 2026

Prerequisites

Before checking memory usage, make sure you have:

  • SSH access to your VPS
  • Your server IP address and password

Method 1: Using free Command (Quick Overview)

Connect to your VPS:

ssh hxroot@YOUR_SERVER_IP -p 22

Human-readable format:

free -h

Example output on a 8GB VPS:

              total        used        free      shared  buff/cache   available
Mem:           7.8G        2.5G        4.2G        123M        1.1G        4.8G
Swap:          2.0G        0.0G        2.0G

Understanding the output:

  • total - Total installed RAM
  • used - Currently used RAM
  • free - Completely unused RAM
  • available - RAM available for new processes (important metric)
  • buff/cache - RAM used for caching (can be freed if needed)

💡 Always look at "available" column, not "free". Linux uses free RAM for caching which is normal.

Regular format (in MB):

free -m

In gigabytes:

free -g

Method 2: Real-time Monitoring with top

top

In top, press M to sort by memory usage. Memory is shown in the SUMMARY area.

%Cpu(s):  2.5 us,  0.5 sy,  0.0 ni, 96.8 id,  0.1 wa,  0.0 hi,  0.1 si,  0.0 st
MiB Mem :   7980.0 total,   4250.0 free,   2500.0 used,   1230.0 buff/cache
MiB Swap:   2048.0 total,   2048.0 free,      0.0 used

Method 3: Using htop (Better Visualization)

htop

If not installed:

apt install htop -y

htop shows memory as a colored bar at the top and memory use per process.

Method 4: Using vmstat (Detailed Stats)

vmstat -s

Shows detailed memory statistics:

      8178892 K total memory
      2560000 K used memory
      4250000 K free memory
      1230000 K buffer memory

Real-time updates:

vmstat 2

(Updates every 2 seconds)

Method 5: Check Memory via Hostxpeed Portal

Your Hostxpeed client area shows live memory stats:

  1. Log in to Hostxpeed Client Area
  2. Go to My Services
  3. Click your VPS service
  4. Look for the RAM Usage card (e.g., 32.7% - 2.5 GB / 8 GB)

Find Top Memory-Consuming Processes

ps aux --sort=-%mem | head -10

Output shows top 10 processes by memory usage.

Get process names and memory in MB:

ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head -10

Check Memory Per User

for user in $(ps -eo user | sort | uniq); do echo -n "$user "; ps -u $user -o rss= | awk '{sum+=$1} END {print sum/1024 " MB"}'; done

Monitor Memory Changes Over Time

watch -n 5 free -h

Press Ctrl+C to exit.

Understanding Memory Types

  • Physical RAM - Actual memory modules
  • Swap - Disk space used as virtual RAM (slower)
  • Cache/Buffer - RAM used for file caching (can be freed automatically)
  • Shared - Memory shared between processes

What is Normal Memory Usage?

  • 2GB VPS - 60-80% used is normal
  • 4GB VPS - 40-60% used is normal
  • 8GB VPS - 30-50% used is normal
  • 16GB+ VPS - 20-40% used is normal

⚠️ High memory usage + high swap usage = Server needs more RAM or process optimization.

Set Up Memory Alert Script

#!/bin/bash
THRESHOLD=90
MEM_TOTAL=$(free | grep Mem | awk '{print $2}')
MEM_USED=$(free | grep Mem | awk '{print $3}')
MEM_PERCENT=$((MEM_USED * 100 / MEM_TOTAL))
if [ $MEM_PERCENT -gt $THRESHOLD ]; then
    echo "Warning: Memory usage at ${MEM_PERCENT}% on $(hostname)" | mail -s "Memory Alert" admin@example.com
fi

Free Up Memory Without Reboot

Drop caches (safe to run):

sync && echo 3 > /proc/sys/vm/drop_caches

Restart memory-hungry services:

systemctl restart mysql

✅ You can now monitor and understand memory usage on your Hostxpeed VPS.

Was this article helpful?