
As a developer working on a low-RAM Linux laptop (4GB or 8GB), I was constantly running into performance issues. Every time I fired up Next.js, opened VSCode, or launched the Brave browser, my system slowed down-or worse, froze entirely. After some digging, I discovered the OOM Killer (Out of Memory Killer) was terminating my apps when RAM ran out.
The fix? I created virtual RAM (a swap file), and it worked like magic.
Here’s exactly how I did it.
Virtual RAM (or swap memory) uses part of your storage (HDD/SSD) as emergency backup RAM. While it’s much slower than physical RAM, it prevents crashes and keeps your system responsive when memory is tight.
This is a one-time setup. Works on any Debian/Ubuntu-based distro.
sudo swapoff /swapfile
sudo rm /swapfile
# For 4GB swap
sudo fallocate -l 4G /swapfile
# Or for 8GB swap
sudo fallocate -l 8G /swapfile
⚠️ If you see “fallocate failed: Text file busy”, make sure to disable the old swap file first using
sudo swapoff /swapfile.
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
swapon --show
free -h
You should now see your swap file listed with the total size (4.0G or 8.0G).
To make the most of your system:
🛑 Close Brave tabs - each tab can take hundreds of MBs.
🧹 Stop services you don’t need.
🌄 Use local static assets instead of heavy external image URLs.
🔁 Use NODE_OPTIONS="--max-old-space-size=4096" when starting Node.js apps.
With virtual RAM, my Linux laptop now runs smoother, handles Next.js builds without crashing, and doesn’t freeze when I open multiple apps.
It won’t make your system faster than real RAM, but it prevents those frustrating crashes that kill productivity.
If you’re building on a budget machine, try it. It might just save your workflow like it did mine.
💬 Let me know in the comments if it helped - or if you have more tips to share!
0
8
0