Python Monitoring Memory Usage with free & /proc/meminfo
The `free` command reports total, used, free, shared, buff/cache, and available physical RAM and swap memory. Understanding the difference between "free" memory and "available" memory is essential: Linux proactively utilizes unused RAM for disk caching.
"Unused RAM is wasted RAM: Linux uses empty memory like a quick-access desk staging area (cache). The moment an application requests RAM, Linux instantly evacuates the cache."
Deep Dive: How It Works
free vs available: "Free" is completely untouched memory; "Available" is the real metric indicating memory ready for new applications without swapping.
buff/cache: Page cache storing files read from disk and I/O write buffers.
Swap: Disk-backed virtual memory used when physical RAM is exhausted.
Syntax Blueprint
free -h # Human readable (GB/MB) free -m # Display in Megabytes cat /proc/meminfo # Low-level raw kernel memory metrics
Use free -h to inspect available system memory and swap usage.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Thinking the system is running out of memory because buff/cache is taking up 80% of RAM.Why it happens: Linux keeps inactive file pages cached in RAM to speed up disk reads.
How to fix: Check the "available" column: Linux frees cache instantly when apps demand memory.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Extract MemTotal from /proc/meminfo
Use `grep "MemTotal" /proc/meminfo` to print the total system RAM.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.