How can I get Linux to not thrash and just kill processes?

Firefox (and flash) tends to chew up memory at random times, causing my computer to thrash, and it drives me crazy waiting for the oom_killer to kick in and kill processes,[1] while I can't do anything to kill firefox myself. I've disabled swap, but that just made it worse. It thrashes for hours before killing anything, and it makes no sense. Why doesn't it just flush a big chunk of the cache and keep going?

Can I disable caching? Can I make it stop thrashing? I just want the biggest memory hog to die when I'm out of memory.

[1] Nevermind that it doesn't actually target firefox, and proceeds to kill X or my desktop environment instead.


Drop your cache periodically. That way, when processes request small amounts of memory, your computer's not busy caching out small bits at a time. Slows down your computer overall, but at least you won't be sitting there waiting for it to thrash when flash eats you alive.

while sleep 30; do vmstat && echo 3 > /proc/sys/vm/drop_caches && vmstat; done


Nov 11 10:40:59 eeyore kernel: [604280.360966] icedove-bin invoked oom-killer: gfp_mask=0x201da, order=0, oom_adj=0, oom_score_adj=0
Nov 11 10:40:59 eeyore kernel: [604280.606183] Out of memory: Kill process 12767 (firefox-bin) score 325 or sacrifice child
Nov 11 10:40:59 eeyore kernel: [604280.607749] Killed process 12914 (plugin-containe) total-vm:187036kB, anon-rss:14488kB, file-rss:0kB
Nov 11 10:41:23 eeyore kernel: [604305.020890] Xorg invoked oom-killer: gfp_mask=0x201da, order=0, oom_adj=0, oom_score_adj=0
Nov 11 10:41:24 eeyore kernel: [604305.096299] Out of memory: Kill process 12767 (firefox-bin) score 325 or sacrifice child
Nov 11 10:41:24 eeyore kernel: [604305.096308] Killed process 482 (plugin-containe) total-vm:61124kB, anon-rss:2420kB, file-rss:0kB
Nov 11 10:41:30 eeyore kernel: [604311.107726] python invoked oom-killer: gfp_mask=0x201da, order=0, oom_adj=0, oom_score_adj=0
Nov 11 10:41:30 eeyore kernel: [604311.531604] Out of memory: Kill process 12767 (firefox-bin) score 325 or sacrifice child
Nov 11 10:41:30 eeyore kernel: [604311.533284] Killed process 12767 (firefox-bin) total-vm:1388764kB, anon-rss:659040kB, file-rss:0kB