How to limit RAM for everyone and everything in Linux?

elementary OS 0.3.2 Freya => Built on Ubuntu 14.04 

For example, I have 6GB of RAM installed, I need to set a limit, beyond which not to rise. For example, I set the limit to 4GB, for the OS it should be the maximum.

On Windows, this is installed in MSconfig. Unfortunately about analogs in Linux, I do not know.

  • what's the point? I ask because the question is very similar to the xy problem . - aleksandr barakin
  • @alexanderbarakin if the question is asked, then it makes sense. - remotemethod
  • I do not argue. probably i have poorly worded. I asked not about the meaning of the question, but about the goal you want to achieve. just not using some of the memory is of course possible. but I assume that it actually requires a memory limit on each process . - aleksandr barakin
  • @alexanderbarakin is exactly that for each process, just the last memory sector is damaged, so you need a limit so that it does not reach this sector. - remotemethod
  • I added the answer. - aleksandr barakin

1 answer 1

if you really need to limit the linux program to the use of RAM, you should pass it as a parameter (when booting):

 mem=желаемый_размер 

eg:

 mem=4G 

instructions for the transfer of additional. parameters of the linux program on the example of the ubuntu distribution.


update due to clarification in comments.

the last memory sector is damaged

then you should probably reserve the right block of memory. This can be done using the parameter (at boot):

 memmap=nn[KMG]$ss[KMG] 

meaning: reserve nn (kilo-, mega-, giga-) bytes of memory, starting with the address ss (kilo-, mega-, giga-) bytes.

An example is to exclude the use of memory from 0x18690000 to 0x1869ffff:

 memmap=64K$0x18690000 

or

 memmap=0x10000$0x18690000