While trying to increase the size of the APC segment on my development machine I suddenly started getting “apc_mmap: mmap failed: Cannot allocate memory” in my error_log. This also made Apache angry, so it refused to return any pages while the error message was present.
After removing the apc.shm_size again, things went back to working as normal.
A bit of psychic debugging and reading phpinfo() output revealed the culprit:
Do NOT include a “M” specifier when providing a size for apc.shm_size. Leave it off. It will assume MBs anyways. This solved the issue.
This is in contrast with the manual page, where it has been documented with a default value of “32M”, while phpinfo() says “32”. This behaviour change with APC 3.1.4, so if your version is older than that you’ll have to use the format without the M.
Mats. As soon as I saw your lifesaver I recalled I had seen this mentioned elsewhere and immediately it clicked … was the solution for me!
It’s a real bummer … really tripped me up as i transferred php etc settings from a machine I thought was the same … same Ubuntu version etc etc.
Another difference caught me out … I thought both machines were mmap compiled but the new machine would only accept **apc.mmap_file_mask=/dev/zero** and not **apc.mmap_file_mask=/tmp/apc.XXXXXX**
So thanks!
Linux has usually a default limit of 32MB per segment.
Source: http://www.marcusnyberg.com/2011/06/20/segmentation-fault-11-core-dumped-in-php-on-freebsd/
> Do NOT include a “M” specifier when providing a size for apc.shm_size. Leave it off. It will assume MBs anyways. This solved the issue.
YMMD! Thanks for this one!
Teddai
Thanks for the solution! Had no idea why it was working on one server and not another until I came across this page
You are a star. I would never have worked this out and would have had another joyful day staring at logs and Top. I dedicate my stress free cup of Tea to you.
Thanks so much!
I got the same problem but it’s strange that the APC version 3.1.9 on Cent OS would not produce this problem while the 3.1.3 on Ubuntu would.
The behaviour changed in 3.1.4, so 3.1.3 on Ubuntu require you to use the format without “M”, while 3.1.9 accepts the M notation.
As of the most recent version of APC the suffix M or G is required. Not supplying one yields you a notice telling you this is a mistake.
Also worth noting, I encountered this problem because the shm size I specified was larger than my system would allow.
Thanks Mate!
That did the trick.
dREI