I've seen plenty of memory related questions on Ubuntu, and to be honest I really can't understand how it is still possible to struggle with such issues.

I have 8GB RAM. I've experimenting with/without swap without much differences.

The problem is that I frequently (up to once a day) have to hard reboot my laptop because it's entirely frozen (waiting does not help). It's most probably related to RAM usage of my web browsers. Appart from this, no high demanding process is running on the laptop.

In order to experiment/reproduce:

  • I "fill" my memory with Python with an infinite loop that fill a list.
  • I open my (web) browser (either Chrome / Firefox), with one or more tabs.

My observations are:

  • Python cannot allocate memory infinitely: it will eventually raise a MemoryError.
  • the browser in the other hand, does not give a f*** about it, and will, in my case, hang the system. I have to hard reboot the laptop then.

I'm do not understand:

  • why the browser is allowed to allocate more and more memory (to the very last bit it seems)
  • why does the system hangs instead of "just" killing a process.

I'm aware that swapping requires CPU, so it may hang the system for a while. That's why I disabled it, so I was thinking that the kernel would rapidly decide to kill a process.

I can't understand how such a basic usage (using browsers) could be a problem with a recent OS using 8GB RAM. Do I need to tweak my system in order to have a reliable one?

Thanks for any advice / explanation / tricks that would help.

  • Have you actually confirmed that your memory is the culprit (and if so that it's the browser)? Perhaps through system monitor or 'free -h' in terminal? You can also use the command 'top' and then press < til sorted by memory use. If chrome runs out memory I believe it gives you an out of memory message too.
    – mock_blatt
    May 4, 2018 at 16:03
  • 1
    Note: Under linux there is an Out-Of-Memory Process (The OOM Killer) that will kill the process hogging a lot of RAM when the system needs more. I think you might find that there is some other bug happening here. Can you update your post with your Kernel version (uname -r) Thanks
    – Bazz
    May 9, 2018 at 3:53
  • This is probably the same issue : askubuntu.com/questions/1031707/…
    – Bazz
    May 9, 2018 at 4:04
  • See also: bugs.launchpad.net/ubuntu/+source/linux/+bug/159356
    – Bazz
    May 9, 2018 at 4:17
  • Thanks for your comments guys... I don't find any really satisfactory answer, and find it weird. Like, we're in 2018 and I don't manage to get a reliable Linux base system, it's quite a shame. Having system freeze on a daily basis is terrible for me, my nerves, and my work...
    – pltrdy
    May 17, 2018 at 12:00

1 Answer 1


I've solved a similar problem with a memory/cpu watcher script and just have it kill any processes that it sees that have more than x ram or y memory for longer than t seconds. That doesn't solve the problem of reserving CPU/Mem for the OS, but it is a workaround until you find a better answer (And when you do, share it with me, because I got here looking for the same thing)


# Kill POS if we're doing stupid shit.
while true; do
    # This is pulling CPU, change the awk column from 9 to something
    # that you want to check against.
    HOG=$(top -b -n 1 | grep pos2 | awk '$9 > 90 {print $1}')
    # If the hog variable is not empty, add some counter info - we don't
    # want to catch periodic spikes, we want to catch consistent offenders.
    if [ ! -z "$HOG" ]; then
        HOG_COUNTER=$(expr ${HOG_COUNTER} + 1)
        echo "$counter_time - Found a hog: $HOG - ${HOG_COUNTER} counters." >> high_mem_kill_log
    # If we have more than 2 counters (3 or more) then we kill the process
    # that's doing it.
    if [ $HOG_COUNTER -gt 2 ]; then
        echo "$kill_time - Found a hog: $HOG.  $HOG_COUNTER counters.  Killing $HOG." >> high_mem_kill_log
        kill $HOG
    sleep 30s
  • Thanks for sharing this. It's definitely interesting! I still feel uncomfortable with this since it seems like a workaround to me (that's why I +1 but not validate for now). Nice first post :)
    – pltrdy
    Nov 5, 2018 at 13:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .