Hacker News new | ask | show | jobs
by deepbreath 2514 days ago
I committed the grave mistake of purchasing a laptop with only 8GB ram and I constantly run out of memory as a result. When it happens, I just repeatedly mash alt+sysrq+f until it kills off some chromium tabs and unfreezes my machine. It essentially behaves like one of those extensions that lets you unload tabs. If needed, you can get the tab back by just reloading the page. The machine slows down to a crawl at 96% usage, and freezes at 97% usage (according to my i3 bar).
5 comments

A few months ago I upgraded my system to 8GB RAM and I don't see the behavior you describe. It does require a little more care when choosing which programs to use[1], but not significantly so. However, you do need to make sure you have swap enabled to let the kernel efficiently manage its resources. It's not unusual for me to have 1-2 GB of stuff in swap; this doesn't affect performance significantly since it's parts of the system that don't need to run, but if you insisted that they all stay resident then it would put a considerable strain on the system in low memory conditions.

[1] The big one for me is that I can't run the Atom text editor, Firefox, and a virtual machine all at the same time.

I run 8GiB without swap. It kills processes off quite nicely when hitting OOM as there is no time wasted with paging out to slow storage.
> slow storage

Linux recently gained the ability to swap huge pages to NVMe without having to split them. Combined with THP this can be quite fast.

How recent? Did this happen back in the 4.x series or is it new to the 5.x series?
4.14 contains some of the changes I read about. But the patch notes are different than what I originally read, I'm not sure whether this is the full feature or whether some of it stalled.
>[1] The big one for me is that I can't run the Atom text editor, Firefox, and a virtual machine all at the same time.

Is this on Linux? I have no problem with that workload on an 8GB Macbook Air (2019). I was apprehensive about going with the 8GB model, but I've not really had any issues.

I wonder if memory compression on OS X helps here.

Yes, this is Linux. I say "can't run" but what I really mean is that things start to get slower after a while until eventually it becomes annoying. This is probably in part due to my habit of accumulating open tabs and windows, and also because I run KDE which is pretty memory-hungry on its own. If you don't do this or you're the sort of person who shuts down your computer every night you might never see this problem so it's hard to compare just based on the list of programs.
Are you swapping to the “VM” section of your APFS container on an insanely fast PCIe (NVMe?) SSD? That’s my guess. Although macOS does a great job of handling poorly behaved programs that use tons of RAM just to begin with.
I'm sure the fast SSD helps to mitigate the relatively small amount of RAM, yes. I can't say to what extent.
And I cannot install more than 4 Gb (thanks to Intel for planned obsolence) and have to use several Electron-based programs (each takes not less than 500 Mb). When there is not enough memory, the system can freeze to the point that I cannot even move a mouse pointer.
> have to use several Electron-based programs

Have you thought about running browser-based versions? I tend to find that these behave a lot better.

Maybe I will try it, but in my case I run them isolated under another user account so it means that I will have to run several instances of a browser (but I'll try to compare the memory usage). Because I don't want them to install cookies and track me across the Internet.
Firefox Containers is a great way of doing this without having to run separate browsers

https://addons.mozilla.org/en-US/firefox/addon/multi-account...

Also incidentally electron apps afaik don't install cookies on your main browser, they should be separate anyway

How do you manage with only 512 MB RAM?
I committed the grave mistake of purchasing a laptop with only 8GB ram and I constantly run out of memory as a result.

I recommend that you try ZRAM. It has made a difference in a 8GB laptop that I use: https://www.cnx-software.com/2018/05/14/running-out-of-ram-i...

For 8GB I run a 2GB ZRAM swap.

How much “extra” RAM does that translate to for your workload?
https://github.com/rfjakob/earlyoom will help you. It will kill those processes for you.
Almost every other laptop comes with an empty RAM slot nowadays, I bet you can plug in an extra few gigs into it.
Not thinkpad x1 carbon