Monitoring and managing system performance on a Linux server or Linux VPS requires understanding how the Linux kernel utilizes physical memory (RAM). When inspecting memory with commands like free -m or top, administrators often notice a large portion of RAM allocated to buff/cache (buffer cache and page cache).
While the Linux kernel automatically manages cache and releases memory when active applications request it, there are specific scenarios where manually clearing or dropping memory caches is necessary for diagnostics, benchmarking, or freeing unreleased memory pages. This guide covers the complete Linux memory diagnostics workflow, how to safely drop caches, and how to monitor CPU and network connections.
How Linux manages memory cache (buff/cache)
Linux follows the philosophy: “Free memory is wasted memory.” Rather than leaving unused RAM idle, the kernel automatically caches recently accessed disk files (Page Cache) and filesystem directory structures (Dentries and Inodes) in memory to dramatically accelerate disk I/O operations.
- Page Cache: Stores disk blocks and files in memory so subsequent reads happen at RAM speeds instead of waiting on disk storage.
- Dentries & Inodes: Caches directory trees, file metadata, and permissions.
- Automatic Reclamation: If an active process (such as MySQL, Nginx, or Docker) requests more RAM, the kernel automatically reclaims cached memory instantly.
When should you manually drop Linux caches?
- Benchmarking & Testing: Clearing cache before running disk I/O or database performance tests to ensure real disk reads are measured rather than cached memory hits.
- Post-Script Cleanup: Releasing memory after running large one-time data imports, file backups, or batch scripts that flooded the cache.
- Diagnosing Low Memory Issues: Verifying true application memory consumption when troubleshooting Out-of-Memory (OOM) errors.
Step-by-step: How to safely drop caches in Linux
Step 1: Always run the sync command FIRST (Critical)
Before telling the kernel to drop caches, you must force all unwritten (dirty) pages sitting in RAM to be written permanently to your disk. Skipping this step can lead to data loss or filesystem inconsistency:
sudo sync
Step 2: Drop specific cache layers via /proc
The Linux kernel provides the /proc/sys/vm/drop_caches interface. You can select the specific level of cache to clear:
Option 1: Free PageCache only
sudo sync && echo 1 | sudo tee /proc/sys/vm/drop_caches
Option 2: Free Dentries and Inodes (Directory structures)
sudo sync && echo 2 | sudo tee /proc/sys/vm/drop_caches
Option 3: Free ALL caches (PageCache, Dentries, and Inodes)
sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches
How to verify RAM usage before and after
Check the immediate reduction in cached memory using the human-readable free command:
free -h
Look at the buff/cache column before and after running the drop_caches command. The available column indicates the true memory capacity available for new applications.
Essential Linux VPS diagnostics: CPU, ports, and network
When troubleshooting overall server load alongside memory:
1. Check CPU allocation and active cores:
lscpu
# Or view active processes by CPU consumption:
top -o %CPU
2. Check listening ports and network daemons:
sudo ss -tulpn
# Or legacy netstat:
sudo netstat -tulpn
3. Check active network connections and remote IPs:
sudo ss -tn state established
For enterprise-grade cloud servers with dedicated high-speed NVMe storage and full root autonomy, explore Aminserve Linux VPS and Windows RDP hosting with 1Gbps ports and 24/7 dedicated support.








