2

I'm new to Linux and Terminal (or whatever kind of command prompt it uses), and I want to control the amount of RAM a process can use. I already looked for hours to find an easy-t-use guide. I have a few requirements for limiting it:

  1. Multiple instances of the program will be running, but I only want to limit some of the instances.
  2. I do not want the process to crash once it exceeds the limit. I want it to use HDD page swap.
  3. The program will run under WINE, and is a .exe.

So can somebody please help with the command to limit the RAM usage on a process in Linux?

hammereditor
  • 39
  • 1
  • 4
  • See this: http://unix.stackexchange.com/questions/44985/limit-memory-usage-for-a-single-linux-process – MiJyn Jul 04 '13 at 00:18
  • I have already looked at that source many times, and it is not useful since it does not give the full code after "$pdftoppm". – hammereditor Jul 04 '13 at 11:20

1 Answers1

2

The fact that you’re using Wine makes no difference in this particular context, which leaves requirements 1 and 2. Requirement 2 –

I do not want the process to crash once it exceeds the limit. I want it to use HDD page swap.

– is known as limiting the resident set size or rss of the process, and it’s actually rather nontrivial to do on Linux, as is demonstrated by a question asked in 2010. You’ll need to set up Linux control groups (cgroups). Fortunately, Justin L.’s answer gives a brief rundown on how to do so. Note that

  • instead of jlebar, you should use your own Unix user name, and
  • instead of your/program, you should use wine /path/to/Windows/program.exe.

Using cgroups will also satisfy your other requirements – you can start as many instances of the program as you wish, but only those which you start with cgexec -g memory:limited will be limited.

Community
  • 1
  • 1
Benjamin Barenblat
  • 1,311
  • 6
  • 19