My old 2013 MacBookPro Retina, with Debian GNU/Linux and 8GB of RAM, was quite slow when using Firefox with multiple tabs.
These optimisations gave it a new life without spending money on hardware.
Problem
Firefox is a RAM devourer. With several tabs open, especially modern websites (heavy JavaScript applications), it is easy to saturate 8GB of RAM. When this happens, the system starts using swap on disk, which causes freezes and extreme slowness.
Solution in two parts
1. Optimise Firefox
Install uBlock Origin:
- Go to: Menu → Add-ons → Search «uBlock Origin»
- Blocking ads and unnecessary scripts easily frees 1-2GB of RAM
Enable automatic tab suspension:
Option A – Native configuration:
about:config
Search for browser.tabs.unloadOnLowMemory and enable it (true)
Option B – Extension (more control):
- Install the «Auto Tab Discard» extension
- Configure it to suspend tabs after X minutes without use
Reduce session history (optional):
about:config
Search for browser.sessionhistory.max_entries and reduce to 5-10 (default: 50)
Alternative: Try Brave If Firefox is still too heavy, Brave is a Chromium based browser but more efficient with RAM:
bash
sudo apt install brave-browser
2. Configure zram (compressed RAM)
What is zram? zram creates a compressed swap device in RAM. Instead of writing to disk when memory fills up (slow), it compresses data in the RAM itself (fast). It typically achieves compression ratios of 2-3:1, effectively giving 10-12GB of «useful» RAM on an 8GB system.
Installation:
bash
sudo apt install zram-tools
Configuration:
bash
sudo nano /etc/default/zramswap
Configure it like this:
bash
# Algoritmo de compresión (lz4 es rápido)
ALGO=lz4
# Porcentaje de RAM a usar para zram (50% = ~4GB)
PERCENT=50
# Comenta SIZE si usas PERCENT
#SIZE=512
# Prioridad alta (usa zram antes que swap en disco)
PRIORITY=100
Enable:
bash
sudo systemctl enable zramswap
sudo systemctl start zramswap
Verify that it works:
bash
zramctl
# Deberías ver algo como:
# NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
# /dev/zram0 lz4 3.8G ...
free -h
# Verás el swap total aumentado
3. Adjust swappiness (optional)
By default, Linux uses a swappiness value of 60, which means that it starts using swap relatively early. With zram, you can lower it so that it uses physical RAM more first:
bash
# Ver valor actual
cat /proc/sys/vm/swappiness
# Configurar permanentemente a 10
echo "vm.swappiness=10" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
Expected results
After applying these optimisations:
- Firefox can handle more tabs without saturating the system
- Fewer «freezes» when the RAM fills up
- Smoother switching between applications
- Drastic reduction in the use of swap on disk (less SSD wear)
- A more responsive system in general
Monitoring the system
To see zram in action:
bash
# Ver uso en tiempo real
watch -n 2 zramctl
# Ver estadísticas detalladas
watch -n 2 'cat /sys/block/zram0/mm_stat'
Tested hardware
- MacBook Pro Retina 13″ (2013) with 8GB RAM
- Debian with XFCE
- Firefox with web development (multiple tabs, DevTools)
Conclusion
With these optimisations, an 8GB system can behave almost like a 10-12GB one for most tasks. It does not replace having more physical RAM for very heavy workloads (massive compilations, intensive virtualisation), but for web development, light backend programming and daily use, the difference is notable.