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 22Human-readable format:
free -hExample 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.0GUnderstanding 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 -mIn gigabytes:
free -gMethod 2: Real-time Monitoring with top
topIn 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 usedMethod 3: Using htop (Better Visualization)
htopIf not installed:
apt install htop -yhtop shows memory as a colored bar at the top and memory use per process.
Method 4: Using vmstat (Detailed Stats)
vmstat -sShows detailed memory statistics:
8178892 K total memory
2560000 K used memory
4250000 K free memory
1230000 K buffer memoryReal-time updates:
vmstat 2(Updates every 2 seconds)
Method 5: Check Memory via Hostxpeed Portal
Your Hostxpeed client area shows live memory stats:
- Log in to Hostxpeed Client Area
- Go to My Services
- Click your VPS service
- 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 -10Output shows top 10 processes by memory usage.
Get process names and memory in MB:
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head -10Check 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"}'; doneMonitor Memory Changes Over Time
watch -n 5 free -hPress 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
fiFree Up Memory Without Reboot
Drop caches (safe to run):
sync && echo 3 > /proc/sys/vm/drop_cachesRestart memory-hungry services:
systemctl restart mysql✅ You can now monitor and understand memory usage on your Hostxpeed VPS.