dongya9904 2017-05-12 06:05
浏览 134
已采纳

Localhost不断报告:PHP致命错误:允许的内存大小为262144字节耗尽(试图分配704384字节)

I've got XAMPP running on my local Windows machine to process some simple text files using PHP. It's a fresh install so there's no history of issues prior.

I get the following error:

PHP Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 704384 bytes)

I thought the solution would be pretty easy. I've tried increasing the memory size to 256M (not 256MB!), I've also tried the bytes version of it (268435456). There was only php.ini in the C:\xampp\php folder, there's nothing in the apache\bin regarding php.ini

Also tried setting the memory manually in the script itself using

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

With no luck. The task itself is very basic - reading in a 640KB file.

Any ideas on what I else I can try?

  • 写回答

1条回答 默认 最新

  • dongqiuxu2270 2017-05-12 06:54
    关注
    ini_set('memory_limit', '256M');
    

    or

    php.ini  =>  memory_limit = 256M
    

    or

    php_value memory_limit 256M
    

    PHP's config can be set in multiple places:

    1. master system php.ini (usually in /etc somewhere)
    2. somewhere in Apache's configuration (httpd.conf or a per-site .conf file, via php_value)
    3. CLI & CGI can have a different php.ini (use the command php -i | grep memory_limit to check the CLI conf)
    4. local .htaccess files (also php_value)

    Also note that PHP generally has different .ini files for command-line and webserver-based operation. Checking phpinfo() from the command line will report different values than if you'd run it in a web-based script.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀