doushou3814 2016-10-20 07:27 采纳率: 100%
浏览 83

WordPress PHP致命错误:内存不足(分配2097152)(试图分配4096字节)

There are many questions already asked about this error, but I could not find a solution for my situation, so I created a new one where I hope to get answers to two very specific questions:

1. Where from does the number 2097152 come?

In my php.ini I have memory_limit set to 256M, in my wp-config.php I have WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT set to 256M, so I would expect to get errors stating that 268435456 bytes were allocated and exceeded, where from 2097152 comes?

2097152 = 2048K = 2M, I looked through all the files in Apache, PHP and WordPress folders and could not find any of these values used, please help.

2. Why is amount that was tried to allocate (4096) is less than allocated (2097152)?

Could someone please explain, what am I missing here?

  • 写回答

1条回答 默认 最新

  • dounie5475 2016-10-20 07:34
    关注

    You may be using too much memory for your PHP application. Possible cause could be infinite loops, too much data loaded to a variable/array(may be coming from the database) etc. You should not rely on increasing the memory size but rather find what's causing the problem and solve it there.

    Use

    error_log("Memory Usage: " . (memory_get_usage()/1048576) . " MB");
    

    and place it on specific locations on your code where you suspect that there's a memory leak or seems that causes the problem.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用