Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Fix the eAccelerator "Could not allocate bytes" Error

This guide helps you fix an error that says eAccelerator could not allocate memory and names a maximum size the kernel allows. It needs root access.

VPS and Cloud Servers2 min read11 steps

What does the error mean?

eAccelerator is an old PHP add-on that makes websites faster. It keeps ready-to-use copies of PHP code in memory. This memory is called shared memory, because many programs can use it at once.

The kernel is the core of the operating system. It sets a limit on the biggest piece of shared memory a program may ask for. The limit is called shmmax.

The error appears when eAccelerator asks for more memory than the kernel allows. The message looks like this:

eAccelerator: Could not allocate xxx bytes, the maximum size the kernel allows is xxx bytes

Tip: eAccelerator is old and newer PHP versions do not support it. Newer servers use OPcache. The fix below still helps for any program that needs shared memory.

Fix 1: Ask for less memory

  1. Log in to your server over SSH as root.
  2. Find the PHP settings file. Run php --ini to see where it is. The eAccelerator settings may also be in a file named eaccelerator.ini.
  3. Open the file with a text editor such as nano.
  4. Find this line:
    eaccelerator.shm_size="64"
    The number is the size in megabytes.
  5. Lower the number, for example to 32 or 16.
  6. Save the file and restart your web server. For Apache run systemctl restart httpd on AlmaLinux or CentOS, or systemctl restart apache2 on Ubuntu.

Fix 2: Raise the kernel limit

  1. Check the current limit:
    sysctl kernel.shmmax
    It shows the number in bytes.
  2. Set a bigger limit for now. This example is 128 MB:
    sysctl -w kernel.shmmax=134217728
  3. To keep it after a reboot, add this line to /etc/sysctl.conf:
    kernel.shmmax = 134217728
  4. Apply the file:
    sysctl -p
  5. Restart your web server.

Warning: make a copy of any file before you edit it. A wrong value can stop the web server from starting. Also, never set the limit above the RAM you really have.

Tip: If you cannot use root on your plan, ask Hostvento support to change the setting. You can also switch to OPcache, which comes with modern PHP.

Quick recap

  • The error means eAccelerator asked for more shared memory than the kernel allows.
  • Lower eaccelerator.shm_size to fix it fast.
  • Or raise kernel.shmmax with sysctl.
  • Restart the web server afterwards.
  • Think about moving to OPcache.