PHP内存耗尽 [英] PHP Memory exhausted

查看:135
本文介绍了PHP内存耗尽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


 致命错误:允许的内存在
/ home / frich中尝试了33554432个字节的大小(试图为

分配9792个字节) /public_html/creation/systemc/sMain/upload_image.php
on line 77


在以下行上

  $ oldImage = imagecreatefromjpeg($ img); 

PHP从HTML表单抓取图片并调整大小。



如果它的一个小文件工作得很好。即几百KB



用一个更大的文件尝试,因为我想要一个高达4MB的最大值。
我遇到的图片是ca. 2mb

预先感谢

解决方案

p>

 
致命错误:允许的内存大小33554432字节耗尽(试图

分配9792字节)在/home/frich/public_html/creation/systemc/sMain/upload_image.php在线77



<这表明,或者你正在使用共享主机,因为你的服务器memory_limit是32 MB



你需要增加你的内存限制,如上面所说的Pekka和 MartyIX



但是,您如何做到这一点,有三种方式可以做到这一点。

1st。 问你的托管公司增加你的内存限制,他们将增加到48MB的最大限度,这是任何托管公司的剪切托管帐户的限制。

/ p>

2nd。上传一个php.ini文件



memory_limit = 100M和max_memory = 100M

您可以将100M更改为您想要的任意大小,但可以限制为不使用额外的服务器资源否则您的帐户可能会被您的托管公司暂停使用限制:此选项可能无法在每个托管服务器上正常工作,因为此代码可能会被管理员阻止,因此服务器资源可能会在LIMIT中消耗。

3rd 上传一个.htaccess

写在里面php_value memory_limit 32M



默认情况下,您可以先下载它,因为它也有其他设置。
下载它用记事本打开并写入php_value memory_limit 32M



4th 选项为您的页面添加PHP代码


$ b ini_set('memory_limit','32M'); (未经我测试,可能工作正常)

感谢和问候........


Any ideas why I'm getting ....

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to

allocate 9792 bytes) in /home/frich/public_html/creation/systemc/sMain/upload_image.php on line 77

on the following line

$oldImage = imagecreatefromjpeg($img);

The php grabs an image from a HTML form and resizes it.

Works perfectly fine if its a small file. I.e. a few hundred KB

Tried with a larger file as I want a max of up to 4mb. The image I get an error with is ca. 2mb

Thanks in advance

解决方案

You are getting error

""""""""""""""""""""""""
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to

allocate 9792 bytes) in /home/frich/public_html/creation/systemc/sMain/upload_image.php on line 77
""""""""""""""""""""""""

It shows that either you are using a shared hosting because your server memory_limit is 32 MB

You need to increase your memory limit as said above by "Pekka" and "MartyIX"

but how you do this there are three ways of doing so.

1st. ask your hosting company to increase your memory limit,

they will increase it upto 48MB max that is the restriction of any hosting company for sheared hosting acount.

2nd. upload a php.ini file

with written "memory_limit = 100M and max_memory = 100M"

you can change 100M to any size that you want but that can be in limit so that it will not use extra resources of server else your account may be suspended by your hosting company

LIMITATION: this option may not work properly on every hosting because some times this code may be blocked by admin so that server resources may be consumed in LIMIT.

3rd upload a ".htaccess"

written inside it "php_value memory_limit 32M"

or

by default it is available in your hosting web directory then you can first download it as it is having other settings too. download it open it with notepad and write "php_value memory_limit 32M"

and

4th option add a PHP code your page

"ini_set('memory_limit', '32M');" (Not tested yet by me, may it work fine)

Thanks and Regards........

这篇关于PHP内存耗尽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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