How to Solve opcache error: zend_mm_heap corrupted

There are always problems with production. It seems that the memory is full, which makes it impossible to request


1. Machine clusters are built with containers
2. The request always appears 502, and it will appear after restarting PHP FPM

3. Open the error log configuration

Of course, you can’t turn off opcache directly. You will find that there is no cache. The memory is very high

Open the error log, and the log will appear in/var/log/PHP FPM/error.log

VI/etc/php-fpm.d/w8002.conf # select different conf files according to which group you want to change
Add a line at the end: catch_ workers_ output = yes

Php5.6 has been reported Zend_ mm_ Heap corrupted with standard PHP 5.6: locating the cause and “Zend”_ mm_ “Heap corrupted” looks like a memory explosion. After a turn, it’s the problem of opcache. Try to disable it, modify the configuration in php.ini and restart PHP FPM

View PHP error log

[root@ip php-fpm]# grep zend error.log | tail -n 3
[01-Jun-2021 00:21:01] WARNING: [pool www8002] child 20812 said into stderr: "zend_mm_heap corrupted"
[01-Jun-2021 00:27:49] WARNING: [pool www8002] child 32582 said into stderr: "zend_mm_heap corrupted"
[01-Jun-2021 00:28:06] WARNING: [pool www8002] child 339 said into stderr: "zend_mm_heap corrupted"

cat php.ini | grep "opcache"
1. /etc/php.d/opcache.ini 改 "opcache.enable=0"
2. systemctl restart php-fpm

Key point: of course, you can’t turn off opcache directly. You will find that the cache memory is too high, so you can’t turn off opcache directly. Let’s start tuning opcache

; switch on

; available memory, as appropriate, in megabytes

Maximum number of files to cache, try to increase this value if the hit rate is less than 100%

opcache.max_accelerated_files=5000 ; Opcache will check the modification time of files within a certain period of time, here set the check time period, the default is 2, in seconds

The memory size of the interned string, also adjustable

whether to fast shutdown, the speed of reclaiming memory will be increased when PHP Request Shutdown is turned on

Do not save file/function comments

Reference Links:

Read More: