Home  >  Q&A  >  body text

The allowed memory size of X bytes has been exhausted

<p><br /></p><blockquote> <p>Fatal error: Allowed memory size of 67108864 bytes exhausted (attempted to allocate 13965430 bytes)</p> </blockquote> <p>PHPInfo shows that my memory limit is 128M, so I'm confused why the error says I only have 64M. Is it possible that phpinfo reports an error? Or does PHP use two separate php.ini? </p> <p>The error was caused by an ini_set call in one of the main php files that one of my colleagues added without my knowledge. </p>
P粉176203781P粉176203781391 days ago430

reply all(2)I'll reply

  • P粉312195700

    P粉3121957002023-08-28 16:05:35

    ini_set('memory_limit', '128M');

    or

    php.ini  =>  memory_limit = 128M

    or

    php_value memory_limit 128M

    reply
    0
  • P粉445750942

    P粉4457509422023-08-28 13:27:06

    PHP configuration can be set in multiple places:

    1. Main systemphp.ini (usually somewhere in /etc)
    2. Somewhere in the Apache configuration (httpd.conf or a per-site .conf file, via php_value)
    3. CLI and CGI can have different php.ini (use the command php -i | grep memory_limit to check the CLI configuration)
    4. Local .htaccess file (also known as php_value)
    5. Inside script (via ini_set())

    In the output of PHPinfo, the "Master" value is the compiled default value, and the "Local" value is the actual effective value. It can be left unchanged from the default value or overridden in any of the above locations.

    Also note that PHP typically has different .ini files for command line and web server-based operations. Checking phpinfo() from the command line will report different values ​​than running it in a web-based script.

    reply
    0
  • Cancelreply