I don't have a lot of memory and sometimes, when I play video games, its get full and my computer start freezing, anything I do take more than 1 minutes before getting done that include mouse move and mouse click.
So what I want is to be able to kill some process I use and I know I can kill (like my Internet browser) before the memory get full so I have little more space left. Do you know a way to do it ?
In technical terms, what I want is that when the memory is almost full it trigger a script that will send a SIGTERM (order to close) to my Internet browser so my PC don't freeze and I can choose to save whatever I'm doing and reopen my browser or forget about my browser.
Thanks for your help.
Alright, here goes:
Put this into
/home/USERNAME/bin
, executechmod +x ~/bin/SCRIPTNAME
, and then add it to your auto-start programs throughSystem->Preferences->Startup Applications
.Then the script will run when you log in, automatically. You can run it manually with
~/bin/SCRIPTNAME &
Killing anything to conserve memory is a bad idea, especially automatically. Make sure that you have enough swap and RAM available - of course, running something that uses 1 gig of memory on a 512MB machine is like trying to win a F1 Grand Prix while driving a Corolla.
By which I mean "don't do it."
The kernel does that automatically when you run out of memory.
If you have swap enabled, however, that will take a lot of grinding.
Try setting vm.swappiness to 100 as per the instructions here (use 100 instead of 0) On a memory starved machine that can improve performance. https://help.ubuntu.com/community/SwapFaq#What%20is%20swappiness%20and%20how%20do%20I%20change%20it?