This is a follow-up to Memory limiting solutions for greedy applications that can crash OS?: ulimit and cgroups are not user friendly, and besides, wouldn't work with applications that spawn separate processes, such as Chrome/Chromium for each new (group of) tabs.
The simple and effective solution, used by Windows 7 actually, is to warn the user that the OS is running low on memory. This simple warning pop-up has prevented me from having any low-memory-caused system freeze in Windows, while I kept running into them on Ubuntu distros that I was testing live (where the RAM-mounted disk would eat up 2GB alone).
So, is there some way to automatically warn the user that the available RAM is nearing zero, without the user having to keep an eye on some memory monitoring gadget? Surely Conky could be configured to do that?
Check these scripts: Need application/script alerting when system memory is running out
PHP:
Another script that I wrote for this purpose:
This cron job that runs every 1 min
To add it you run
crontab -e
and paste it at the bottom. You have to have cron installedUpdated above script to also add details on top 3 memory-hungry processes. See at https://github.com/romanmelko/ubuntu-low-mem-popup
Here is the script itself:
Variant using RAM available, percentages and displays desktop notifications when called by cron (i.e. loop script doesn't have to be started after reboot):
Updated version of the script which works with free from procps-ng 3.3.10
I've created simple program which triggers linux notification and check ram interval of 5 seconds if RAM goes more than equal to 80 then it triggers notifications.