How to i calculate the size of shared memory available to the system

memoryshared memory

According to the rhel document, the total amount of shared memory available on the system equals to shmall*PAGE_SIZE.
After I completed the installation of RHEL6, the value of the shmall kernel parameter defaults to 4294967296,which means that the total amount of shared memory pages that can be used system wide is 4294967296, and the page size is 4096B. So, based on the formula, the size of shared memory is

4294967296*4096/1024/1024/1024/1024=16TB

which is much more than the size of RAM(8GB) the operating system has.How an os can find 16TB shared memory to allocate?

So, is the size of /dev/shm actually equal to the size of shared memory? If not, how can I get the actual size of shared memory?

Best Answer

Your calculation is correct. shmall can be set higher than the available virtual memory. If you would try to use all of it then it would not fail because of shmall is exceeded but because of other reasons.

BTW there are also commands to find these IPC limits:

ipcs -l
lsipc  # util-linux>=2.27

Note that even the virtual memory is unlimited on Linux by default, greater-than RAM+swap. See

https://serverfault.com/questions/606185/how-does-vm-overcommit-memory-work

How the OOM killer decides which process to kill first?

On the other hand you could limit the virtual memory per process using ulimt -v which wouldn't affect kernel's /proc/sys/kernel/shmall neither.

Related Question