Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On my machine (Linux Mint x64, intentionally zero swap), programs like Firefox and Chrome (running at the same time, because then need to, unfortunately) end up consuming a lot more memory than they have any reason to. And when they go wrong, the whole machine halts.

How do I force some of these tasks to be forcibly limited to a specific memory footprint that they are fully aware of so that they don't try to overrun their maximum memory footprint?

I'm sick and tired of programs like Chrome and Firefox screwing me because they just randomly (from a user perspective) decide, "Hey, I need more memory. Kernel, I need more memory!" instead of "Hey, I need more memory... Crap, I'm out. What do I cut?"

Best I can find, so far is to isolate Chrome and Firefox (individually) to VMs on some other machine with locked-in maximum memory footprints. But, that is highly wasteful, and turns out horribly for things like flash games, especially ones that expect hardware acceleration.

God only knows what is using so much memory, because each browser generally doesn't have more than 15 tabs open. So, that's a further frustration.

How do I force certain programs to live within a certain memory footprint that they are well aware of?

While this question could be limited to just Chrome or Firefox, I'm sure there are other highly wasteful programs that need some kind of restraint. So, while a solution that fixes Firefox and Chrome bad behavior may do what I need, a more general solution is really what I'm wanting.

share|improve this question

You can use:

  • control groups (cgroups]) on your main OS.
  • lxc instead of VMs with cgroups memory control.

For a reference of all options in the kernel for memory control you can check here.

This solution applies to any program or group of programs.

share|improve this answer

You can use ulimit to set the maximum memory of processes launched via the current terminal, or use a program like softlimit to launch a program with a given memory limit. Once that limit is reached, memory allocations will fail with ENOMEM (which may not be correctly handled by all programs).

share|improve this answer

You must log in to answer this question.

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