Feb 15, 2012

APC minimal shm size


What is the minimal amount of shm Space APC needs to operate properly? I’m currently running a WordPress blog on a VPS based on virtuozzo and I can’t set kernel shm to anything above 32 mb. Is there any way of telling APC to use “normal” memory instead of shared one (I’ve got plenty of ram…)

My current apc.ini looks like this, yet apc tells met that it’s using just 30 MB (1 Segment(s) with 30.0 MBytes (mmap memory, pthread mutex locking)):

extension = apc.so
apc.enabled = 1
apc.shm_segments = 15
apc.num_files_hint = 2700
apc.user_entries_hint = 2700
apc.ttl = 7200
apc.user_ttl = 3600
apc.gc_ttl = 600
apc.cache_by_default = 1
apc.max_file_size = 2M
apc.stat = 1
Asked by schneida


Found the solution myself:

By default apc now uses mmap for shared memory. In theory, mmap should not be bound to the maximum shm size by the kernel, but it seems it is, at least in shared server environments like virtuozzo. Also mmap ignores apc.shm_segments because it won’t create multiple anonymous files to map into memory without a mask, so unless you also set apc.mmap_file_mask this seems to be useless.

Another way is to recompile apc using --disable-apc-mmap and use IPC shared memory instead!

Answered by schneida

Related posts:

  1. APC configuration on Ubuntu 10.4. Problem with apc.shm_size, apc.shm_segments and Apache
  2. apc apc.shm_segments ignored apc.shm_size behaving weird in apache2
  3. PHP Warning: PHP Startup: apc.shm_segments setting ignored in MMAP mode
  4. /dev/shm (shared memory) on linux
  5. Limit APC opcode caching to specific sites? Nginx + PHP-FPM + APC

Leave a comment