PHP致命错误:内存不足(分配80740352)(试图分配12352字节)中 [英] PHP Fatal error: Out of memory (allocated 80740352) (tried to allocate 12352 bytes) in

查看:529
本文介绍了PHP致命错误:内存不足(分配80740352)(试图分配12352字节)中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



error msg isPHP致命错误:内存不足(已分配80740352)(试图分配给用户) 12352字节)in / home .......
如何使用php.ini来修复这个问题?



这是我目前上传的php。 ini设置

pre $ upload $ max_filesize = 2000M;
post_max_size = 2000M
max_file_uploads = 8

还有什么我需要的添加解决这个错误?

解决方案

最佳 memory_limit 值取决于你在做什么与上传的文件。你是否使用file_get_contents或GD库将文件读入内存?在这种情况下,将memory_limit增加到至少与upload_max_filesize相同,最好是更多。



如果使用GD,请记住GD保存整个图像在内存中未压缩。这意味着它占用宽度*高度*位深度范围内的内存,例如 1024 * 768 * 32 = 25 165 824位= 3 MB 为一个截图,或者一个14兆像素图像高达55 MB。

有些操作可能需要创建一个副本图像,所以考虑将memory_limit设置为将图像保存在内存中所需的两倍。如果不需要,也请确保不要将所有图像一次加载到内存中。您可以通过在完成图像处理后调用手柄上的 imagedestroy 来释放GD使用的内存。


I get this error when users are uploading images on my site.

error msg is "PHP Fatal error: Out of memory (allocated 80740352) (tried to allocate 12352 bytes) in /home......." How can I fix this using php.ini?

Here is my current upload php.ini settings

upload_max_filesize = 2000M ;
post_max_size = 2000M
max_file_uploads = 8

Any ideas what else I need to add to solve this error?

解决方案

The optimal memory_limit value depends on what you are doing with the uploaded files. Do you read the files into memory using file_get_contents or the GD library? In that case, increase memory_limit to at least the same as upload_max_filesize, preferably more.

If you are using GD, keep in mind that GD holds the entire image uncompressed in memory. This means that it takes memory in the range of width * height * bit-depth, e.g., 1024*768*32 = 25 165 824 bits = 3 MB for a screenshot, or as much as 55 MB for a 14 megapixel image.

Some operations may need to create a copy of the image, so consider setting memory_limit to the double of what you need to keep the image in memory. Also make sure to not load all images into memory at once if you don't have to. You can free the memory used by GD by calling imagedestroy on the handle when you are done working with the image.

这篇关于PHP致命错误:内存不足(分配80740352)(试图分配12352字节)中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆