Found on SatckOverFlow. I love it :
ps -eo pid --no-headers --sort=-%mem | head -1 | xargs kill -9
With:
ps -eo pid --no-headers --sort=-%mem
: display the process ids of all running processes, sorted by memory usagehead -1
: only keep the first line (process using the most memory)xargs kill -9
: kill the process