Always SWAP!

August 11, 2023
LG Gram

I bought my LG Gram 2022 last year in August after considerable deliberation. I wanted a laptop for work and the two options that were at the top of my list were:

  • Asus ROG Zephyrus G14 2022 &
  • LG Gram 2022 16"

I had my heart set on G14 at the time but ASUS didn't launch the laptop until Dec 2022. I was starting my new job in August and had to buy one. I chose to go with LG Gram 2022 because I've been fascinated by the laptop since LG launched it in 2015. The 13" model weighed only 1kg, which it still does in 2023, and was considered an engineering marvel.

I bought the 2022 16" model and it weighs a mere 1.2kg. I fell in love with this laptop. It's easy to carry everywhere and with its black color, it's a looker. It has a full-sized keyboard, a bright and large 2k 16" screen (with razor-thin bezels that maintain its small-ish footprint), a responsive touchpad, etc. I didn't regret buying the laptop a bit.

Until it started freezing.

I work in Drupal development. Most of my projects use DDEV (it's Docker-based) and I work on 4-5 projects at a time. I use Chrome for work and Firefox for personal use. I have multiple VSCode instances open at a time and I also use the Slack desktop app. 

A couple months ago the laptop started freezing up whenever I opened a lot of tabs or lots of VSCode instances or lots of project instances etc. If I was multitasking for a long time, the laptop froze. And by froze I don't mean started acting slow. I mean straight-up frozen. Unresponsive touchpad, unresponsive keyboard, not able to switch apps etc.

The first time this happened, I thought maybe it was a one time thing and probably happened because I haven't restarted the laptop in a long time. But then it became a regular thing where the laptop froze almost every other day.

The laptop has 16GB of RAM and I realized that whenever the RAM usage reached that level, the laptop started freezing up.

This was disappointing. I didn't want to regret buying a laptop that I really loved and that I just bought a year ago. So I went into troubleshooting mode. 

The first thing that came to my mind was to upgrade RAM. But then I realized that Gram 16 has soldered RAM and I didn't have any way to upgrade it. More regret!

Then I started looking into whether it could be something with my OS. I use Linux Mint. Linux is superfast for my Docker-based workflow. I removed the pre-installed Windows and installed Linux Mint the day I got the laptop. 

And the moment I thought about a fault in OS, I realized that it's the OS's responsibility to manage memory when memory consumption is high. And most OS use the process of "Swapping" to manage memory.

Swapping is a process of creating temporary storage space on a SSD/HDD when the system runs low on memory. The file swaps a section of RAM storage from an idle program and frees up memory for other programs. 

I realized that swapping must not be working properly on my laptop. 

And then I realized that it's not working at all!!!

I remembered that when I set up Linux Mint on my laptop a year ago, I didn't create a SWAP partition. I am not exactly sure why I did that. I must have thought (or read somewhere) that I might not need SWAP with 16GB of RAM. And oof, was I wrong.

The first thing I did after this realization was to set up SWAP. And then I stress-tested the laptop. I started all my projects, opened all of them in separate VS Code instances, Opened tons of tabs in Chrome & Firefox, etc. Eveyrthing I did, the laptop took it as a champ and didn't freeze once. It did slow down a little when I overdid things, but never froze.

So I am back in love with my laptop. It's still a champ. 

Readers, don't make the mistake I made. Always SWAP!

 

P.S.

I know SWAP is not a replacement for RAM. If your system have to often fall back to SWAP, it's probably better to upgrade RAM. But when you can't, it sure can be a lifesaver.