Php – APC shared memory problems

freebsdPHPphp-fpm

i have nginx+php-fpm and APC installed on a freebsd server, and i'm experiencing constant problems with php-fpm connected somehow with APC. php-fpm freezes in 'lockf' state (in top) and thus site is not working.
i noticed that by lowering apc.shm_size to its default value 30 is helping php-fpm not to freeze, but 30Mb is not enough for me, because i store a lot of variables in APC.
i noticed that raising apc.shm_size to higher values (as 60) makes php-fpm processes to use a lot more memory, practically all of the server physical memory, which is strange because as i understood those 60Mb are shared between all php-fpm processes and should not affect on memory usage of every php-fpm process.
i tried to change apc.shm_segments value to something more than 1 and got an error on restarting php-fpm:

PHP Startup: apc.shm_segments setting ignored in MMAP mode in <b>Unknown</b> on line <b>0</b><br />
Unknown(0) : Warning - PHP Startup: apc.shm_segments setting ignored in MMAP mode

so please tell me how do really those parameters affect on APC and why do php-fpm dies when using big amount of shared memory? what means MMAP mode?
i'm thinking of swithing to xcache, is it working with php-fpm and stable enough for production?

Best Answer

About mmap:

Configure script of apc has directive:

  --disable-apc-mmap
                          Disable mmap support and use IPC shm instead

Also there is 3 types of locking:

  --enable-apc-sem
                          Enable semaphore locks instead of fcntl
  --enable-apc-spinlocks
                          Enable spin locks  EXPERIMENTAL

+Default fcntl. You can try spinlocks and see what happens

PS. This should be useful too: http://www.php.net/manual/en/apc.setup.php