Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
1  
How much RAM do you have? How much swap? Most likely the reason it can't flush a big chunk and keep going is that the current working set size (amount of memory accessed in a short period of time) exceeds the physical memory. I'd start out by removing any tuning you've done. –  David Schwartz Nov 6 '11 at 13:05
    
In theory, you could disable the kernel's memory overcommiting system - that way, Firefox should segfault when it chews up all of your system's memory, instead of waiting for the OOMKiller. –  new123456 Nov 6 '11 at 20:37
1  
@DavidSchwartz I don't think you read my question. It doesn't matter how much RAM I have. Things (firefox/flash) leak and take up more memory than they should and I just want them to die so I can restart them without having to wait for thrashing to finish. I have this problem on more than one machine, with 512MB-4GB of RAM. There is no swap partition, as I don't want things to swap. If I'm out of memory, I just want things to die. The working set size really can't exceed the physical memory because there is no swap. –  Jayen Nov 6 '11 at 23:16
    
@new123456 I will try disabling it, but then what if firefox chews up the available memory (and no more), and then other processes request more memory? That would kill the other processes before killing firefox, right? I guess that is a rare enough case, though, so it's probably better than the thrashing I have now. –  Jayen Nov 6 '11 at 23:18
    
@new123456 it looks like too many programs depend on being able to overcommit. things just crash without it. i'm going to try dropping caches every 30s and see if that helps. –  Jayen Nov 7 '11 at 0:07

1 Answer 1

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 > 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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.