Increase shared memory on linux (shmmax)

Linux Shared memory shmmaxShared memory is often used in many applications on linux such as Oracle, Tibco, Webmethods. It’s also used for php extensions such as eaccelerator.

In this tutorial, I will show you how to increase the shared memory limit permanently.

The shared memory is stored in the following file: /proc/sys/kernel/shmmax

To check the size of your shmmax, write the following command:

cat /proc/sys/kernel/shmmax

you will see the number of maximum shared memory in bytes.

There are three ways to change the maximum limit. In the below examples, I will set the maximum shared memory to 64 MB (64 * 1024 * 1024 = 67108864)

First Method

This method is not permanent and will be reset once the server is rebooted:

echo 67108864 > /proc/sys/kernel/shmmax

 

Second Method

This method is permenant, the file sysctl.conf will be loaded during the boot process:

echo “kernel.shmmax=67108864” >> /etc/sysctl.conf

 

Third Method

This method is also permanent, but requires to edit the sysctl.conf directly:

vi /etc/sysctl.conf

and append the following:

kernel.shmmax=67108864

Make sure to save the file using :w

If you use the second or third method, you will need to restart your server for the changes to take effects.
To restart your server, write the following command:

/sbin/reboot

or:

/sbin/shutdown -r now

Any questions? Leave us a comment below!

 

Leave a Reply

Your email address will not be published. Required fields are marked *