# pecl-APC Cannot allocate memory error



## Mayhem30 (Aug 20, 2012)

When Apache (or APC?) triggers a graceful restart at 12am every Sunday, I am getting this error message :


```
[Mon Aug 20 00:00:02 2012] [warn] (22)Invalid argument: Failed to enable the 'httpready' Accept Filter
PHP Fatal error:  PHP Startup: apc_shm_create: shmget(0, 134217728, 914) failed: Cannot allocate memory.
It is possible that the chosen SHM segment size is higher than the operation system allows. Linux has usually a default limit of 32MB per segment. in Unknown on line 0
PHP Fatal error:  PHP Startup: apc_shm_attach: shmat failed: in Unknown on line 0
```

This shuts down the whole server.

However, I am able to do a graceful restart and normal restart on Apache without this error showing up.

Any ideas what is causing this?

FreeBSD 7.4-RELEASE-p3 || nginx/1.2.3 || Apache/2.2.22 || pecl-APC 3.1.12 || PHP 5.3.15


sysctl.conf :

```
kern.ipc.shmmax=134217728
```



```
localhost# sysctl kern.ipc.shmmax
kern.ipc.shmmax: 134217728
```


----------



## Mayhem30 (Aug 21, 2012)

Solved : 

Because you're attempting a graceful restart you're going to require double the shm_size as you will have new processes as well as processing yet to have exited, the previous memory cannot be free'd until those requests have completed.

https://bugs.php.net/bug.php?id=56539

In a nutshell, *kern.ipc.shmmax* needs to be double the size of your APC cache ONLY IF you have enabled : IPC shm memory support (default: mmap) - in your pecl-APC options.


----------

