php system_error ai_generated true

Warning: PHP Startup: Unable to allocate interned strings buffer: 2097152 bytes in Unknown on line 0

ID: php/opcache-interned-strings-buffer

Also available as: JSON · Markdown · 中文
90%Fix Rate
88%Confidence
1Evidence
2023-08-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
PHP 8.0 active
PHP 8.1 active
PHP 8.2 active
PHP 8.3 active
OPcache 8.0 active
OPcache 8.1 active

Root Cause

OPcache's interned strings buffer is too large for the available shared memory, typically due to a misconfigured `opcache.interned_strings_buffer` value exceeding the system's shared memory limits.

generic

中文

OPcache 的内部字符串缓冲区太大,超出了可用的共享内存,通常是由于 `opcache.interned_strings_buffer` 配置值超过了系统的共享内存限制。

Official Documentation

https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.interned-strings-buffer

Workarounds

  1. 90% success Reduce `opcache.interned_strings_buffer` in php.ini to a smaller value, e.g., from 16 to 8: `opcache.interned_strings_buffer = 8`
    Reduce `opcache.interned_strings_buffer` in php.ini to a smaller value, e.g., from 16 to 8: `opcache.interned_strings_buffer = 8`
  2. 75% success Increase the system shared memory limit by modifying `/etc/sysctl.conf` with `kernel.shmmax = 2147483648` and `kernel.shmall = 2097152`, then reload with `sysctl -p`.
    Increase the system shared memory limit by modifying `/etc/sysctl.conf` with `kernel.shmmax = 2147483648` and `kernel.shmall = 2097152`, then reload with `sysctl -p`.
  3. 85% success Check available shared memory with `ipcs -lm` and adjust `opcache.interned_strings_buffer` to a value that fits within the system limits; a safe starting point is 4 MB.
    Check available shared memory with `ipcs -lm` and adjust `opcache.interned_strings_buffer` to a value that fits within the system limits; a safe starting point is 4 MB.

中文步骤

  1. 在 php.ini 中将 `opcache.interned_strings_buffer` 减小到较小的值,例如从 16 改为 8:`opcache.interned_strings_buffer = 8`
  2. 通过修改 `/etc/sysctl.conf` 增加系统共享内存限制:`kernel.shmmax = 2147483648` 和 `kernel.shmall = 2097152`,然后使用 `sysctl -p` 重新加载。
  3. 使用 `ipcs -lm` 检查可用共享内存,并将 `opcache.interned_strings_buffer` 调整为适合系统限制的值;安全起始值为 4 MB。

Dead Ends

Common approaches that don't work:

  1. 95% fail

    The error is about allocation failure; increasing the value increases memory demand.

  2. 60% fail

    The error only affects startup; disabling OPcache is unnecessary if the buffer size is adjusted.

  3. 90% fail

    The issue is a persistent configuration problem, not a transient system state.