PostgreSQL cannot allocate memory on Mac OS X
asked 14 Sep '11, 11:12
When PostgreSQL is included as part of a Mac installer, you may find the following error in some machines during database initialization:
This problem is related to the fact that some OS X systems are configured with an amount of shared memory which may not be enough to run postgreSQL depending on other applications that may be installed in the machine.
You can workaround this by modifying kernel parameters, running the following as root:
This can be made permanent adding the following lines to /etc/sysctl.conf.
You may consider showing a more specific error message that redirects the user to a detailed description about how to fix the issue. You can do this by checking the returned error message as follows:
What EnterpriseDB includes in its readme file about shared memory is shown below:
PostgreSQL uses shared memory extensively for caching and inter-process communication. Unfortunately, the default configuration of Mac OS X does not allow suitable amounts of shared memory to be created to run the database server.
Before running the installation, please ensure that your system is configured to allow the use of larger amounts of shared memory. Note that this does not 'reserve' any memory so it is safe to configure much higher values than you might initially need. You can do this by editting the file /etc/sysctl.conf - e.g.
On a MacBook Pro with 2GB of RAM, the author's sysctl.conf contains:
Once you have edited (or created) the file, reboot before continuing with the installation. If you wish to check the settings currently being used by the kernel, you can use the sysctl utility:
The database server can now be installed.
For more information on PostgreSQL's use of shared memory, please see:
answered 14 Sep '11, 11:17