# Damn you OOM Killer!!

## Cyker

I'm running a recent beta of Opera and it has a memory leak issue; I'm sure it will be fixed eventually, but in the meantime it's triggering some very nasty behavior in the kernel, namely the dreaded OOM Killer! :O

When it's triggered, I'd expect it to take out Opera, but not only does it kill opera but apache, qtorrent, thunderbird, VirtualBox and several instances of kedit and rxvt!

Is there something I can do about this, e.g. to make it only kill Opera and not go on a mad killing spree with my other apps? :S

----------

## frostschutz

Yeah sure there's an easy solution. Don't run Opera. Or at least not a beta that leaks memory that badly.

An alternative may be adding more swap. If the leaked areas are large enough they can simply be paged out and never ever be paged in again, keeping your physical memory free of bloat.

Yet more obscure alternative is to have a script running in the background that checks Opera's memory usage frequently, and kills it directly before it grows big enough to trigger OOM. However this will only work if the leakage is somewhat continuous... if it just allocated too much memory instantly there is no easy way to react to it in a script.

Whether it's possible to set "preferred" applications for OOM, I don't know.

----------

## Cyker

That's the bizarre thing; The swapfile doesn't even get touched!

It just fills up RAM then kills a semi-random set of processes. TBH I'm not very happy about that behavior - Even once Opera is fixed, it'll still be there - So I want to find out what I could do..

I suspect there's some low-memory allocation problems going on which is why the swap isn't even being touched, but how to fix that and/or disable the oom-killer or make it only kill the process with the largest RAM allocation or lower priority processes or something would be better solutions for me...

----------

## xibo

GDB can set rlimits for programms it runs... Why not run opera in gdb ( don't know if that works )?

If opera is not swapped it's probably doing accesses to all of it's memory pages regularily, which would be weird, but could happen nevertheless

----------

## frostschutz

 *Cyker wrote:*   

> That's the bizarre thing; The swapfile doesn't even get touched!

 

Two possibilities... you set swappiness to zero. Or the memory is allocated in a way that can not be swapped. Programs are allowed to do that, some even need to do that (for example memtester, if it allows its allocated memory to be swapped out, how can it reliably test the physical memory?). Of course combining that with a memory leak is absolutely deadly.

Which brings us back to square one: If the Opera Beta is that bad do not use it! Wait for them to fix the issue!

----------

## eccerr0r

Perhaps ulimiting opera's memory may help temporarily?

ulimit -m 262144 # use 256MB memory for this shell and subshells from now on.

ulimit -d 262144 # let data size get no more than 256MB

While this is not the proper solution it may help a little.

This is weird though, opera should not lock its pages... I can see virtualbox/vm's wanting to lock pages in RAM.

----------

## zeek

Try this:

```

echo 15 > /proc/<pid_of_opera>/oom_adj

```

That should guarantee that Opera is killed the next time this happens.  Useful for more than Opera ...

This is good reading to understand OOM killer:

http://lwn.net/Articles/317814/

----------

## phajdan.jr

You can also disable memory overcommit.

----------

