apc_mmap: mmap failed: Invalid argument

I went to adjust the APC cache size on one of my Ubuntu 10.04 LTS (Lucid) servers today. This particular server runs a single app, and it only uses 12M of cache, so I wanted to change the cache size from the default 32M to 16M. I put apc.shm_size=16M in /etc/php5/conf.d/apc.ini and restarted Apache… and to my surprise, Apache didn’t come back up. I found this error in the error log:

[apc-error] apc_mmap: mmap failed: Invalid argument

Which (via Google) led me to this very thorough blog post.

TL;DR, for older versions of APC like the version that ships with Ubuntu 10.04 LTS (APC version 3.1.3p1), you cannot use the “M” suffix. The correct syntax is apc.shm_size=16.

According to this bug report, it looks like APC >= 3.1.4 expects the M/G suffix, so this shouldn’t be an issue with Ubuntu 12.04 LTS (Precise).

Tagged ,

Leave a Reply

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