(转载)PHP的内存限制 Allowed memory size of 134217728 bytes exhausted (tried to allocate 1099 bytes) in
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1099 bytes) in
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1099 bytes) in
解释是可用内存已耗尽,这关系到PHP的memory_limit的设置问题。
这里有两种方法解决
1、修改php.ini
memory_limit = 128
这种方法需要重启服务器,很显然,此方法对虚拟机有限制。
2、通过ini_set函数修改配置选项值
ini_set ('memory_limit', '128M')
ini_set ('memory_limit', '128M')
----------------
PHP5中,对于memory_limit的设定已经从以往的8M扩大到128M的上限。对于配置中的定义解释是: memory_limit = 128M ; Maximum amount of memory a script may consume (128MB) 最大单线程的独立内存使用量。也就是一个web请求,给予线程最大的内存使用量的定义。现有的大部分网站或者论坛应用中,应用软件的配备一般都是以如下的形式搭建: Nginx(Apache)+PHP+Memcache+Mysql 对于以上的应用软件的采用,优点我就不再多说。但对于Memcache的使用就是为了减少对于数据库的访问的频率的降低,也是提高服务响应的一种办法。但是对于memcache和数据库的数据存储有区别的是,memcache的数据并不是以上数据的形式存储在内存中,而是抽象化了之后以字符的形式,hash表的形式存储在内存之中。这样的存储区别导致,每次memcache的数据抽取必须全部数据反序拟化一次,将所有的数据导入进独立的单一线程中,然后第二部才是进行过滤和抽取你所需要的数据。在应用过程中,如果是读取数据库的数据,大家应该知道,优化的办法应该是在SQL语句中比保证第一次过滤尽量是提高准确性,只取需要的字段,不要全部所有字段取出之后再在应用中过滤得到自己想要的字段,这样对于服务器的负载会有本质的区别。
如果采用memcache,必然做不到数据库在在第一次就精确过滤这点目标。那么就需要在开始设计表的同时就需要考虑到这点,尽量保证被memcache数据表尽量保证数据的较少,可以多分表来完成。
memory_limit的内存分配,标配是128M。一旦独立的线程超过了128M,那PHP会报错: Fatal error: Allowed memory size of 33554432 bytes对于8G内存的服务器,如果同时并发的响应达到50,每个都是128M的峰值,那估计也是服务器会卡死的时候。
尽量降低128M的内存配置,如果调整至64M,服务器的负载基本能下降一半左右,如果能调整至32M效果更好。但是对于应用的要求就更高,很多表建立初期就没有考虑到这个问题,如果你要采用memcache作为数据的存储,必须提前完成优化数据表的设计部署,降低独立线程PHP的内存使用量,服务器的响应和负载降低的就不仅仅是几个百分点的效果了。
(转载)PHP的内存限制 Allowed memory size of 134217728 bytes exhausted (tried to allocate 1099 bytes) in的更多相关文章
- PHP的内存限制 Allowed memory size of 134217728 bytes exhausted (tried to allocate 1099 bytes) in
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1099 bytes) in Fa ...
- Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1099 bytes) in
解释是可用内存已耗尽,这关系到PHP的memory_limit的设置问题. 我在网上看到,有两种方法解决 1.修改php.ini memory_limit = 128 这种方法需要重启服务器,很显然, ...
- Allowed memory size of 134217728 bytes exhausted解决办法(php内存耗尽报错)【简记】
报错: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) i ...
- PHP内存溢出Allowed memory size of 解决办法
PHP内存溢出Allowed memory size of 解决办法 博客分类: php ============================Allowed memory size of x ...
- Fatal error: Allowed memory size of 524288000 bytes exhausted (tried to allocate 64 bytes) in D
Fatal error: Allowed memory size of 524288000 bytes exhausted (tried to allocate 64 bytes) in D 从数据库 ...
- Allowed memory size of 134217728 bytes exhausted
错误信息: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65015808 bytes) 由于报错信息和数据库 ...
- php的Allowed memory size of 134217728 bytes exhausted问题解决办法
php的Allowed memory size of 134217728 bytes exhausted问题解决办法 报错: Fatal error: Allowed memory size of 1 ...
- php的Allowed memory size of 134217728 bytes exhausted问题
提示Allowed memory size of 134217728 bytes exhausted,出现这种错误的情况常见的有三种: 0:查询的数据量大. 1:数据量不大,但是php.ini配置的内 ...
- Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 2611816 bytes)
一段PHP程序执行报错: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 261181 ...
随机推荐
- 盗链网易163、腾讯QQ、新浪sina、百度Baidu的图片之PHP独立版
网易相册频道,网易相册确实是一个高质量图片的地方,而且免费,唯一缺点是很多加了水印,但这个不重要了,无意间发现网易163相册频道的图片是防止盗链的,于是便自己写了一个小程序来突破这个. 本盗链图片最新 ...
- linux磁盘设备知识
linux分区数字编号: 1.分区数字编号1至4留给主分区或扩展分区使用,逻辑分区编号从5开始. 2.IDE硬盘设备名均以/dev/hd开头,不同硬盘编号依次是/dev/hda/./dev/hdb./ ...
- hdu 2191 珍惜现在,感恩生活 多重背包入门题
背包九讲下载CSDN 背包九讲内容 多重背包: hdu 2191 珍惜现在,感恩生活 多重背包入门题 使用将多重背包转化为完全背包与01背包求解: 对于w*num>= V这时就是完全背包,完全背 ...
- StringBuffer与StringBuilder原理与区别
其实只要找下Google大神就有答案了:StringBuffer 与 StringBuilder 中的方法和功能完全是等价的,只是StringBuffer 中的方法大都采用了 synchronized ...
- jquery , find the event handler,找到jquery中的event handler
找到 dispatch: function (e) { e = b.event.fix(e); var n, r, i, s, o, u = [], a = d.call(arguments), f ...
- 简易promise
<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8" ...
- windows store app search contract
代码如下: html: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> ...
- Pair Project: Elevator Scheduler [电梯调度算法的实现和测试]:谢勤政-11061197,吴润凡-11061185
一,关于结对编程 结对编程的优点: 1)在开发层次,结对编程能提供更好的设计质量和代码质量,两人合作能有更强的解决问题的能力. 2)对开发人员自身来说,结对工作能带来更多的信心,高质量的产出能带来更高 ...
- 用JavaScript获取一个超链接的绝对URL地址
对于Web程序员来说,处理简单的URL格式也许会成为一场噩梦.试想一下,一个网址里有很多组成部分都会影响你对它的解析方法: 是否以/字符开头 是否以//开头 是否以?号开头 是否以#号开头 …等等 当 ...
- 异常: http://www.ly.com/news/visa.html: java.io.IOException: unzipBestEffort returned null
nutch 运行时异常: http://www.ly.com/news/visa.html: java.io.IOException: unzipBestEffort returned null 参考 ...