htop uses a sophisticated color-coding system to represent system resource utilization at a glance. The default color scheme breaks down as follows:
Green: 0-60% utilization (normal operation)
Blue: 60-80% (moderate load)
Yellow: 80-90% (high load)
Red: 90-100% (critical)
When memory shows minimal green/blue and predominantly yellow (as in your screenshot), this indicates:
- ~10-20% of RAM is in normal usage (green/blue)
- 80-90% of RAM is actively utilized (yellow)
- Swap remains unused (ideal situation)
You can modify these thresholds in ~/.config/htop/htoprc
:
# CPU threshold percentages
cpu_count=4
cpu_green=60
cpu_blue=80
cpu_yellow=90
# Memory thresholds
mem_green=50
mem_blue=70
mem_yellow=85
For a system showing your pattern (high yellow memory), consider these actions:
# Identify memory-hungry processes
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
# Clear page cache (temporary relief)
echo 1 > /proc/sys/vm/drop_caches
Combine htop visualization with precise metrics:
# Live memory breakdown
watch -n 1 "free -h && echo '' && vmstat -s"
When working with htop
, the color-coded bars provide crucial visual indicators about system resource utilization. The default color scheme follows this pattern:
- Green: Represents memory used by processes
- Blue: Shows buffer/cache memory
- Yellow: Indicates memory that's been allocated but not actively used
- Red: Signals swap space usage
The scenario you described - with small green/blue segments and mostly yellow - reveals:
Memory breakdown:
- Active processes (green): Minimal
- Buffers/cache (blue): Small amount
- Inactive memory (yellow): Dominant portion
- Swap (red): Unused (empty bar)
This typically indicates a system where:
- Few active processes are consuming RAM
- The kernel has allocated memory that isn't currently being utilized
- No memory pressure exists (hence no swap usage)
You can modify these thresholds in ~/.config/htop/htoprc
:
# Sample configuration for memory meter colors
color_mem_buffer=38;5;27
color_mem_cache=38;5;39
color_mem_used=46
color_mem_free=148
Here's a bash snippet to log memory patterns similar to htop's display:
#!/bin/bash
while true; do
free -m | awk '/Mem:/ {
printf "Memory: %.1f%% active (green), %.1f%% buffers (blue), %.1f%% inactive (yellow)\n",
$3/$2*100, $6/$2*100, ($5-$6)/$2*100
}'
sleep 5
done
While yellow memory isn't inherently problematic, watch for these patterns:
Color Pattern | Implication |
---|---|
Mostly green | High process activity |
Growing red | Memory pressure |
Green + yellow | Normal operation |
For developers optimizing memory usage, consider:
# Check detailed slab info (requires root)
sudo cat /proc/meminfo | grep -E 'Active|Inactive|Slab'
This helps distinguish between:
- Active memory (green)
- Reclaimable cache (blue)
- True inactive memory (yellow)