Using a userland oom-killer does help a lot with deadlock situations (https://news.ycombinator.com/item?id=22833471)
I wouldn't still recommend Gnome (Default Ubuntu), any other desktop would be lighter on RAM and CPU. KDE, MATE, or Budgie are all great.
I do have a speedy SSD though, when I was on my HDD the pill was quite harder to swallow.
At 4gb, I'd also look at lubuntu. The UI uses less RAM than Gnome and at that amount of RAM, 1-200MB is significant (plus, LXDE uses less CPU power too). I actually run i3 on a lot of older systems to save even more (but you'll have to learn how to using tiling systems -- not hard, but something more to learn nonetheless).
Another comment talked about the RPi 4's capabilities, but mine had multi-second input lag running a fresh install of Ubuntu/Gnome on a single 4k screen.
Note, I used: "systemctl list-unit-files --type=service | grep enabled" to find all enabled services easily and then: "systemd-analyze" for basic timing analysis
Granted I was using Mint with the Cinnamon desktop but i'm sure Gnome with Ubuntu would have been fine too.
I installed Windows 10 on it for a few days to try it out and the difference was night and day. The laptop would pause for about a second every maybe 15 seconds or so, which wasn't a thing on Linux.
The RaspberryPi 4 also only has up to 4GB of RAM and is capable of driving 2 4K screens.