There are times that the simple thing as opening a notepad on our Linux becomes like a navigation through quicksand. That’s because the RAM has been used up.
The knee jerk reaction would be to do “swap tweaking” and closing unused tabs. But beyond these generics, are there any other creative way to free up RAM on Linux?
I use the Cron- Fu Shuffle. How this works is that this technique preloads libraries that are commonly used into memory at boot making your apps to start up at a really good speed. A cron job is then used to swap the preloaded libraries determined by the patterns by which you use apps. With this, your RAM usage adapts to the patterns by which you use apps and frees up precious extra RAM.
So what are your unorthodox approach to free up RAM and stop memory leakages? We can all get to learn.
That’s a pretty slick approach with the Cron-Fu Shuffle! Adapting RAM usage to your app patterns is a smart way to optimize.
Here are a few unorthodox methods I can think of:
ZRAM: It’s a Linux kernel feature that provides a form of virtual memory compression. Unused data in RAM is compressed, freeing up space without needing to use swap. It can be especially effective on systems with limited RAM.
EarlyOOM or NoHang: These are daemons that monitor available memory and automatically kill processes to prevent out-of-memory scenarios. They’re more proactive than the OOM killer that’s built into the kernel.
tmpfs Tweaks: If you’re using tmpfs (temporary file storage in RAM), tweaking its size or disabling it for certain mount points can free up RAM. But, this depends on how much you rely on tmpfs.
Profile-guided Optimization: This is more of a developer approach, but recompiling your most used applications with profile-guided optimizations can make them use memory more efficiently.
Cgroups: Using control groups to limit the memory usage of certain processes can prevent them from hogging all your RAM.
For me, I prefer the approach of a temporary RAM disk. The downside is that data would be lost when system is rebooted but it achieves that simple goal of speeding up access. I use tmpfs with this code: