DEV Community

Cover image for Master your RAM ⚡ to increase the life of your hardware
Amin
Amin

Posted on • Updated on

Master your RAM ⚡ to increase the life of your hardware

Tips & tricks that I use in my day-to-day life as a developer in order to bring older hardware with me on the move and save money.

🏗️ Build inside your RAM

Whether it is a Web, Android, Windows or Linux project that you are working for, chances are that you need to build the final product by using a combination of scripts or tools in order to do so.

Except the artifacts that gets built that way (intermediate files that are needed during the build but not for running the software) will wear out your disk.

Aren't what disks are made for? No, disks are meant to store data, and artifacts don't need to be stored since you can always build or rebuild them somewhere else. What's needed to be stored is the source-code and the executable, that's it.

Even if you need to store your artifacts, you don't need to use your disk in order to build them, use your RAM. It is made for lots of read/writes and chances are that if you are running an older hardware, you can squeeze out some performance by building your project in RAM.

Plus, it reduces the unnecessary wear you are applying to your disk. Again a disk is made for storing data, not for constant compiling, building, transpiling, removing files that could otherwise be done inside your RAM.

For instance, using GNU/Linux or Mac.

$ cd /tmp
$ git clone https://github.com/my-username/my-project
$ cd my-project
$ make build
$ cp build/my-project /usr/local/bin
$ chmod +x /usr/local/bin/my-project
$ my-project
Enter fullscreen mode Exit fullscreen mode

Enjoy faster and safer builds!

🌐 Browse the Web inside your RAM

Most of the time, you are using your browser in order to search your way out of the world wide web for answers to your questions.

By doing so, your browser wants to cache what it can because accessing the internet constantly for displaying your favorite website (like DEV!) is an expensive thing to do.

Each time you go back on DEV, it searches for a cached version of that website, and if so, it will use it instead of going on the internet, bother the DEV server and get the necessary HTML, CSS & JavaScript files in order to browse this site.

This is a costly thing to do, especially for older hardware since the time needed to access that cache might get longer than using your RAM that is made for quick read/writes.

So you can use your RAM in order to speed things up by mounting your browser's cache into RAM and squeeze out some more juice out of your RAM and browse the Web faster.

Note that your cache will get completely wiped out at reboot, and there are software that can help you synchronize your work periodically, which write back the cache on your disk.

This will still wear out your disk, but it will take longer since the synchronization can occur less often, and you can control the way your cache is written back by scripting your way. Plus you get an extra boost since you are browsing the web on your RAM!

In GNU/Linux, you can use profile-sync-daemon in order to synchronize your browser's profile back into your disk.

And if you don't care about data persistence and like to live your life dangerously (or you want maximum privacy and wipe out your browser's cache at each reboot like TAILS do), you can add this simple line to your /etc/fstab file and reboot your computer if you are using Firefox for instance.

tmpfs /home/yourself/.mozilla tmpfs size=1G 0 0
tmpfs /home/yourself/.cache/mozilla tmpfs size=1G 0 0
Enter fullscreen mode Exit fullscreen mode

And I'm sure there are lots of software for Mac & Windows doing a similar job.

📝 Summary

If you need to squeeze out some power on older hardware, chances are that you can get away with using your RAM in order to speed things up, making you save some money and reusing your older hardware (good for our beloved planet Earth).

Keeping your software up to date is also a good solution in order to always be using your operating system at maximum speed.

You can also use a GNU/Linux distribution that is lightweight compared to Mac or Windows in order to get better performances and postpone the day you will have to buy another hardware.

Hope you learned one or two things with this article and see you in the next one!

Top comments (0)