High RAM notification

is there a way to get a notification if your RAM usage gets significantly high?

my system gets semi-regularly out of memory, gets insanely slow for 5-10 minutes until it finally gets to kill something, and it would be nice if I knew early enough so I can e.g. shut down a VM, close my browser or just restart plasma itself if it itself is the culprit (I actually have a hotkey for this)

I have seen a notification AFTER it finally got around to kill things, but frankly when my free ram gets to e.g. <2GB (out of 24 (+2GB Swap)) it’s high time to look into stuff.

also inb4 someone comes with “unused RAM is wasted RAM”, I know from windows task manager that systems can be WELL AWARE of whether ram is actually “in use” or just cache ready to be re-used whenever needed, and I would heavily hope linux has something similar.

today my plasma for example was at 8GB on its lonesome, something seems to be leaking and until I can figure out that properly having at least an early warning so I can act quickly would be useful.