允许内存大小为262144字节(试图分配24576字节)

时间:2022-03-28 11:04:35

I was going crazy with this.

我快要发疯了。

I got the next message:

我收到了下一个信息:

Allowed memory size of 262144 bytes exhausted (tried to allocate 24576 bytes)

TODO LIST

待办事项列表

Check phpinfo(), got the right php.ini route and edit it. Change memory_limit to

检查phpinfo(),得到正确的php。ini路线并编辑它。改变memory_limit来

memory_limit = 128M

Make sure the value memory_limit changes con phpinfo() with the result:

确保值memory_limit更改con phpinfo(),结果如下:

memory_limit    128MB   128MB

Check .htaccess and added (not needed)

检查.htaccess并添加(不需要)

php_value memory_limit 128M

And also to change it via php like so (before error line):

还可以通过php(在错误行之前)更改它:

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

It says everywhere that memory is set to 128M, but still get that error?

它说,内存被设置为128M,但仍然会得到这个错误?

The error is in Swift library (library for sending emails), in abstractSmtpTransport.php, so it's not my code int's suposed to work.

该错误在Swift库(发送电子邮件的库)中,在abstractSmtpTransport中。php,这不是我的代码。

Any ideas???

任何想法? ? ?

Edit: Yes, the previous was done restarting apache.

编辑:是的,之前的任务是重新启动apache。

EDIT 2: @patrick, added that but nothing was echoed

编辑2:@patrick,但没有回音。

Tryed with lower value, 28M int every file, restarted apache, same error (phpinfo showed new value)

使用更低的值,每一个文件都有28M,重新启动apache,同样的错误(phpinfo显示了新值)

tried with -1, restarting, and same error.

尝试用-1,重新启动,同样的错误。

EDIT 3: isn't it weird that allowed memory is bigger than allocated memory? (despite the fact that allowed memory size is way below real allowed memory asigned)

编辑3:允许内存大于分配的内存不是很奇怪吗?(尽管允许内存大小低于实际允许内存的事实)

5 个解决方案

#1


109  

I see my problem is a little bit different from yours, but I'll post this answer in case it helps someone else. I was using MB as shorthand instead of M when defining my memory_limit, and php was silently ignoring it. I changed it to an integer (in bytes) and the problem was solved.

我发现我的问题和你的有点不一样,但是我会把这个答案写出来,以防它会帮助别人。在定义memory_limit时,我使用MB作为简写,而php则默默地忽略它。我将它改为一个整数(以字节为单位),问题就解决了。

My php.ini changed as follows: memory_limit = 512MB to memory_limit = 536870912. This fixed my problem. Hope it helps with someone else's! You can read up on php's shorthand here.

我的php。ini更改如下:memory_limit = 512MB到memory_limit = 536870912。这个固定我的问题。希望它能帮助别人!您可以在这里阅读php的简写。

Good luck!

好运!

Edit

编辑

As Yaodong points out, you can just as easily use the correct shorthand, "M", instead of using byte values. I changed mine to byte values for debugging purposes and then didn't bother to change it back.

正如Yaodong指出的那样,您可以轻松地使用正确的简写“M”,而不是使用字节值。我将我的代码改为字节值以进行调试,然后就不需要再修改它了。

#2


7  

The value of 262,144 bytes is the key to the diagnosis. You'll see this magic number pop up in PHP questions all over the place. Why? Because that is the value PHP will end up with as its memory limit if you attempt to update the limit with a value it can't use. An empty string will produce this memory limit, as will an incorrect unit notation like '128MB' instead of the correct '128M'.

262144字节的值是诊断的关键。你会看到这个神奇的数字出现在PHP的问题中。为什么?因为,如果您试图用它不能使用的值更新限制,那么PHP将以它的内存限制结束。一个空字符串将产生这个内存限制,像“128MB”这样的不正确的单元表示法,而不是正确的“128M”。

262,144 bytes is exactly 256 Kibibytes. Why PHP runs home to that value when it gets confused is beyond me.

262144字节正好是256字节。当我感到困惑的时候,为什么PHP会运行这个值。

isn't it weird that allowed memory is bigger than allocated memory?

允许内存大于分配内存不是很奇怪吗?

The allocated amount shown is just the most recent allocation attempt, the one that ran afoul of the memory limit. See Allowed memory size in PHP when allocating less.

显示的分配金额只是最近的分配尝试,与内存限制相冲突。在分配较少的PHP时,请查看允许的内存大小。

#3


1  

See if this answer can help you. Particularly the fact that CLI ini could be different than when the script is running through a browser.

看看这个答案是否能帮到你。特别是,CLI ini可能与脚本在浏览器中运行时不同。

Allowed memory size of X bytes exhausted

允许内存大小的X字节耗尽。

#4


0  

if you are using models in your application and using get_object_vars($model) and push this to your array , add this function to model :

如果您在应用程序中使用模型,并使用get_object_vars($model)并将其推到您的数组中,请将该函数添加到模型中:

public function  get_objects(){
        return (get_object_vars($this));
    }

and add like this to your array :

然后把它添加到你的数组中:

 array_push($array,$model->get_objects());

#5


0  

I was trying to up the limit Wordpress sets on media uploads. I followed advice from some blog I’m not going to mention to raise the limit from 64MB to 2GB.

我在努力提高Wordpress对媒体上传的限制。我遵从了一些博客的建议,我不打算提及将64MB的限制提高到2GB。

I did the following:

我做了以下几点:

Created a (php.ini) file in WP ADMIN with the following integers:

在WP管理中创建了一个(php.ini)文件,其中包含以下整数:

upload_max_filesize = 2000MB
post_max_size = 2100MV
memory_limit = 2300MB

I immediately received this error when trying to log into my Wordpress dashboard to check if it worked:

当我试图登录我的Wordpress仪表盘检查它是否工作时,我立即收到了这个错误:

“Allowed memory size of 262144 bytes exhausted (tried to allocate 24576 bytes)"

“允许内存大小为262144字节(试图分配24576字节)”

The above information in this chain helped me tremendously. (Stack usually does BTW)

这条链上的信息帮了我很大的忙。(栈通常顺便说一句)

I modified the PHP.ini file to the following:

我修改了PHP。ini文件如下:

upload_max_filesize = 2000M
post_max_size = 2100M
memory_limit = 536870912M

The major difference was only use M, not MB, and set that memory limit high.

主要的区别是只使用M,而不是MB,并设置内存上限。

As soon as I saved the changed the PHP.ini file, I saved it, went to login again and the login screen reappeared.

我一保存修改过的PHP。ini文件,我保存了它,再次登录,登录屏幕再次出现。

I went in and checked media uploads, ands bang:

我进去检查了媒体上传,

Image showing twordpress media folder “Add New” box, with limits stated as “MAXIMUM UPLOAD FILE SIZE: 2 GB”

图片显示twordpress媒体文件夹“添加新”框,其中限制为“最大上传文件大小:2gb”

I haven't restarted Apache yet… but all looks good.

我还没有重启Apache,但是看起来都不错。

Thanks everyone.

谢谢每一个人。

#1


109  

I see my problem is a little bit different from yours, but I'll post this answer in case it helps someone else. I was using MB as shorthand instead of M when defining my memory_limit, and php was silently ignoring it. I changed it to an integer (in bytes) and the problem was solved.

我发现我的问题和你的有点不一样,但是我会把这个答案写出来,以防它会帮助别人。在定义memory_limit时,我使用MB作为简写,而php则默默地忽略它。我将它改为一个整数(以字节为单位),问题就解决了。

My php.ini changed as follows: memory_limit = 512MB to memory_limit = 536870912. This fixed my problem. Hope it helps with someone else's! You can read up on php's shorthand here.

我的php。ini更改如下:memory_limit = 512MB到memory_limit = 536870912。这个固定我的问题。希望它能帮助别人!您可以在这里阅读php的简写。

Good luck!

好运!

Edit

编辑

As Yaodong points out, you can just as easily use the correct shorthand, "M", instead of using byte values. I changed mine to byte values for debugging purposes and then didn't bother to change it back.

正如Yaodong指出的那样,您可以轻松地使用正确的简写“M”,而不是使用字节值。我将我的代码改为字节值以进行调试,然后就不需要再修改它了。

#2


7  

The value of 262,144 bytes is the key to the diagnosis. You'll see this magic number pop up in PHP questions all over the place. Why? Because that is the value PHP will end up with as its memory limit if you attempt to update the limit with a value it can't use. An empty string will produce this memory limit, as will an incorrect unit notation like '128MB' instead of the correct '128M'.

262144字节的值是诊断的关键。你会看到这个神奇的数字出现在PHP的问题中。为什么?因为,如果您试图用它不能使用的值更新限制,那么PHP将以它的内存限制结束。一个空字符串将产生这个内存限制,像“128MB”这样的不正确的单元表示法,而不是正确的“128M”。

262,144 bytes is exactly 256 Kibibytes. Why PHP runs home to that value when it gets confused is beyond me.

262144字节正好是256字节。当我感到困惑的时候,为什么PHP会运行这个值。

isn't it weird that allowed memory is bigger than allocated memory?

允许内存大于分配内存不是很奇怪吗?

The allocated amount shown is just the most recent allocation attempt, the one that ran afoul of the memory limit. See Allowed memory size in PHP when allocating less.

显示的分配金额只是最近的分配尝试,与内存限制相冲突。在分配较少的PHP时,请查看允许的内存大小。

#3


1  

See if this answer can help you. Particularly the fact that CLI ini could be different than when the script is running through a browser.

看看这个答案是否能帮到你。特别是,CLI ini可能与脚本在浏览器中运行时不同。

Allowed memory size of X bytes exhausted

允许内存大小的X字节耗尽。

#4


0  

if you are using models in your application and using get_object_vars($model) and push this to your array , add this function to model :

如果您在应用程序中使用模型,并使用get_object_vars($model)并将其推到您的数组中,请将该函数添加到模型中:

public function  get_objects(){
        return (get_object_vars($this));
    }

and add like this to your array :

然后把它添加到你的数组中:

 array_push($array,$model->get_objects());

#5


0  

I was trying to up the limit Wordpress sets on media uploads. I followed advice from some blog I’m not going to mention to raise the limit from 64MB to 2GB.

我在努力提高Wordpress对媒体上传的限制。我遵从了一些博客的建议,我不打算提及将64MB的限制提高到2GB。

I did the following:

我做了以下几点:

Created a (php.ini) file in WP ADMIN with the following integers:

在WP管理中创建了一个(php.ini)文件,其中包含以下整数:

upload_max_filesize = 2000MB
post_max_size = 2100MV
memory_limit = 2300MB

I immediately received this error when trying to log into my Wordpress dashboard to check if it worked:

当我试图登录我的Wordpress仪表盘检查它是否工作时,我立即收到了这个错误:

“Allowed memory size of 262144 bytes exhausted (tried to allocate 24576 bytes)"

“允许内存大小为262144字节(试图分配24576字节)”

The above information in this chain helped me tremendously. (Stack usually does BTW)

这条链上的信息帮了我很大的忙。(栈通常顺便说一句)

I modified the PHP.ini file to the following:

我修改了PHP。ini文件如下:

upload_max_filesize = 2000M
post_max_size = 2100M
memory_limit = 536870912M

The major difference was only use M, not MB, and set that memory limit high.

主要的区别是只使用M,而不是MB,并设置内存上限。

As soon as I saved the changed the PHP.ini file, I saved it, went to login again and the login screen reappeared.

我一保存修改过的PHP。ini文件,我保存了它,再次登录,登录屏幕再次出现。

I went in and checked media uploads, ands bang:

我进去检查了媒体上传,

Image showing twordpress media folder “Add New” box, with limits stated as “MAXIMUM UPLOAD FILE SIZE: 2 GB”

图片显示twordpress媒体文件夹“添加新”框,其中限制为“最大上传文件大小:2gb”

I haven't restarted Apache yet… but all looks good.

我还没有重启Apache,但是看起来都不错。

Thanks everyone.

谢谢每一个人。