DEV Community

pabli44
pabli44

Posted on

RAM optimization on Ubuntu

SWAP MEMORY

SWAP is a space on your hard drive (SSD/HDD) used as "virtual memory." While it prevents the system from crashing when RAM is full, it is significantly slower than physical RAM.

Swappiness Adjustment (RAM Priority)
We tuned the kernel's swappiness parameter to ensure Ubuntu prioritizes your physical RAM over the slower disk-based Swap.

Temporary Change (Immediate):
sudo sysctl vm.swappiness=10

Permanent Configuration:
Add vm.swappiness=10 to the end of /etc/sysctl.conf.

Technical Explanation
By default, Linux often has a high swappiness value (usually 60). This forces the system to move data to the Swap partition even when there is plenty of RAM available.

For a workstation with 20 GB of RAM, this is inefficient. Using Swap frequently causes "I/O Wait", where the CPU wastes cycles waiting for the disk to respond. By lowering the value to 10, we ensure:

Better RAM Utilization: Your system keeps active processes (like IntelliJ and Chrome) in high-speed physical memory.

Reduced Latency: You eliminate the "stuttering" or lag when switching between windows because the CPU no longer has to retrieve data from the SSD's Swap space.

Optimal Resource Management: The disk is only used as a last resort when the physical RAM is truly exhausted.

This configuration essentially unlocks the full potential of your hardware upgrade, ensuring a "buttery smooth" experience even under heavy dev workloads.



You know, enjoy learning!!

Top comments (0)